Tree获取选中项时,能否把选中项的父节点以及父节点的父节点全部获取,比如三级菜单,最后一级叶子节点选中后,获取选中项前面2项获取不到
let sel = [];
function findPath(selected, children, parent = { root: true }) {
for (var i = 0; i < children.length; i++) {
const item = children[i];
if (selected === item.key) {
sel.push(item);
return;
}
if (item.children) {
findPath(selected, item.children, item);
if (sel.length) {
sel.push(item);
return;
}
}
}
}
问题解决了吗?先关闭
This thread has been automatically locked because it has not had recent activity. Please open a new issue for related bugs and link to relevant comments in this thread.
Most helpful comment