如果选中父级,怎么样设置回显只有父级呢?根据评论区的大佬们修改了点击父级可以全选的代码,现在选中父级的话,会将整个系列全部选中
// 处理单选多选
_fixMultiple(index) {
if (!this.multiple) {
// 如果是单选
this.treeList.forEach((v, i) => {
if (i != index) {
this.treeList[i].checked = false
} else {
this.treeList[i].checked = true
}
})
} else {
this.treeList.forEach((obj, i) => {
if (!this.treeList[index].checked && this.treeList[index].parentId.indexOf(obj.id) > -1) {
this.treeList[i].checked = false;
} else if (obj.parentId.indexOf(this.treeList[index].id) > -1) {
this.treeList[i].checked = this.treeList[index].checked;
}
})
}
},
0 个回复