页面代码:
但是奇怪的是 我点击按钮 进行全选操作时,选择框并没勾上,哪里有问题?
<el-checkbox v-for="item in itemList" :label="item.name" :key="item.id" :disabled="item.disabled" :checked="item.checked">{{ item.name }}
</el-checkbox>
JS代码:
handleCheckedAllItem() {
this.checkAll = !this.checkAll
console.log(this.checkAll)
for(let index=0;index<this.itemList.length;index++){
let temp= this.itemList[index];
temp.checked = this.checkAll
this.itemList.splice(index, 1, temp); //替换数组中这个元素
}
console.log(this.itemList.length)
console.log(this.itemList)
}