tree组件在获取完数据进行页面回显时,因为获取的数据中包含父节点的关系,把不该选中的子节点也全部勾上了。
isLeaf(判断节点是否为叶子节点)
getNode(获取tree中对应的节点)
setChecked (设置tree中对应的节点为选中状态)
let res = [1,11,23,25,28,37];
res.map((i, n) => {
//根据i获取tree中的节点
var node = that.$refs.menuListTree.getNode(i);
if (node.isLeaf) {
//设置某个节点的勾选状态
that.$refs.menuListTree.setChecked(node, true);
}
});
子节点未全部选中时,.checkedKeys中没有包含父节点id。
halfCheckedKeys中为半选中的节点(具体可查看官方API)
//复选框点击
checkboxSelect(data, status) {
this.childId = status.checkedKeys; //用于选中时候的前端页面回显
this.allIdArr = status.checkedKeys.concat(status.halfCheckedKeys); //传给后台的数据
},
本文地址:https://blog.csdn.net/weixin_40881970/article/details/107536469
如对本文有疑问, 点击进行留言回复!!
XSS训练网站XSS Challenges所有题目解(中篇)
如何给未越狱的ios下载历史版本的app?未越狱IOS系统安装历史版本软件的方法,iPhone未越狱的手机如何安装旧版本APP?
Unity Android playerSetting相关设置
网友评论