The vue multi-select box can only be selected for the second time

Problem Description

The assignment is executed at the click of the multi-selection box, which causes the mouse to click the box for the first time. The following is the error reproduction

<template>
	...
	 <el-checkbox label="选项" v-model="type" @change="handleOther"></el-checkbox>
	 <el-checkbox label="选项2" v-model="type2"></el-checkbox>
	...
</template>
<script>
export default{
      
      
	data(){
      
      
		type:false,
		type2:false
	},
	methods:{
      
      
		handleOther(val){
      
      
			this.type = val;//错误步骤
			//其他关联操作
			val ? this.type2 = false : this.type2 = true;			
		}
	}
}
</script>

When clicking, the two-way binding has already modified the value, and there is no need to manually assign the value one more step, otherwise it will result in clicking twice to select the input box

Guess you like

Origin blog.csdn.net/weixin_43939111/article/details/130888305