1、 页面效果
2、后台返回checkbox数据格式
3、实现
el-checkbox-group 所对应v-model 必须是数组格式,且没有层级嵌套
<el-checkbox-group v-model="checkModule">
<el-checkbox v-for="item in checkModuleList" :label="item.dictLabel" :value="item.dictValue" :key="item.dicValue" @change="getcheckModule(item)"></el-checkbox>
</el-checkbox-group>
getcheckModule(item){
if(this.checkarr.indexOf(item.dictValue) == -1){
this.checkarr.push(item.dictValue);
}else{
this.checkarr.splice(this.checkarr.indexOf(item.dictValue),1);
}
this.form.modularIds=this.checkarr;
this.form.modularNames = this.checkModule;
console.log('this.name.--',this.checkModule)
console.log('this.id.--',this.form.modularIds)
},