vue2 el-checkbox-group 复选框无法选中
原代码:
<template slot-scope="scope"><el-checkbox v-model="scope.row.bitian">必填</el-checkbox>
</template>if (this.allTemplateList && this.allTemplateList.length > 0) {this.allTemplateList.forEach(template => {template.bitian = false;template.number = '';template.shangchuandatas = [];template.wenjiandaxiao = '';})
},
修改后:在遍历 this.allTemplateList 时,使用 Vue.set 或 this.$set 来确保新添加的属性是响应式的
if (this.allTemplateList && this.allTemplateList.length > 0) { this.allTemplateList.forEach((template, index) => { this.$set(this.allTemplateList, index, { ...template, bitian: false, number: '', shangchuandatas: [], wenjiandaxiao: '', }); });
}