vue多选框第二次才能选中

问题描述

多选框点击处执行赋值,导致鼠标点击框框第一次木反应。以下为错误重现

<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>

点击时双向绑定已经将值修改,不需要再多一步手动赋值,否则会导致点击两次才能选中输入框

猜你喜欢

转载自blog.csdn.net/weixin_43939111/article/details/130888305
今日推荐