element ui checkbox 复选框 选中其中一个后 其他的都不能被选中
作者:互联网
<el-checkbox-group v-model="checkList" @change="changeList">
<el-checkbox
:disabled="item.disabled"
:label="item.name"
v-for="item in list"
:key="item.name"
></el-checkbox>
</el-checkbox-group>
data(){return{
checkList: [],
list: [
{ disabled: false, name: "GJB5000" },
{ disabled: false, name: "GJB9001" },
{ disabled: false, name: "CMMI" },
{ disabled: false, name: "合同未指定" },
],
}}
changeList(val) {
this.list.forEach((item) => {
item.disabled = false;
});
if (val.indexOf("合同未指定") != -1) {
this.checkList = ["合同未指定"];
this.list.forEach((item) => {
if (item.name != "合同未指定") {
item.disabled = true;
}
});
}
},
标签:checkbox,false,name,list,复选框,disabled,item,未指定,选中 来源: https://blog.csdn.net/qq_36628003/article/details/121229823