iview tree收缩

tech2023-12-26  69

tree 收缩:默认展开根目录,当点击子节点时,展开当前父节点

let currentId = 3; //子节点的父级id function getTree (data) { //data:tree data const arr = []; data.map(item => { let obj = {} obj.title = item.value obj.id = item.id if (item.id === currentId) { obj.selected = true obj.isExpand = true } if (item.children) { obj.children = getTree(item.children) const c = obj.children.find(item => item.isExpand) if (c) { obj.expand = true obj.isExpand = true } } arr.push(obj) }) return arr }
最新回复(0)