Element-ui中Radio组件取消选中
Vue.js使用Element-ui中Radio组件实现点击选中,再点击取消选中功能。
Radio组件
<el-radio-group v-model="detailForm.radioStatus" :key="radioKey">
<el-radio :label="1" @click.native.prevent="changeRadio(1)">已接听</el-radio>
<el-radio :label="2" @click.native.prevent="changeRadio(2)">未接听</el-radio>
</el-radio-group>
变量定义
return {
radioKey: false,
detailForm: {
radioStatus: ''
}
}
Radio点击事件
changeRadio(val) {
this.detailForm.radioStatus= this.detailForm.radioStatus== val ? '' : val
this.radioKey= ! this.radioKey
},