Vue中的element树结构修改功能踩坑
1.修改功能一般是从列表页跳转过来的
var treeCheckedIdList2 = []
this.dataHy.forEach(item => { //dataHy是一个树形结构
this.checkedKeys1.forEach(item1 => { //item1是一个XX,XX1字符串
if (item1.indexOf(item.label) != -1) {
treeCheckedIdList2.push(item.label)
}
})
this.$refs.tree.setCheckedKeys(treeCheckedIdList2, true) //tree是与dataHy挂钩的树
//这都是在一个方法体之内
就是if(item1.indexOf(item.label) != -1){
}一直进不去,所以树结构不会选中
本文介绍了在Vue项目中使用ElementUI进行树结构数据修改时遇到的问题,特别是关于如何在从列表页跳转后正确选中树节点的难点。在尝试通过if判断条件(item1.indexOf(item.label) != -1)来实现选中匹配项时,发现条件始终无法满足,导致树结构无法正常显示已选状态。
726

被折叠的 条评论
为什么被折叠?



