优化代码:修改unexpandAllNode,expandToLevel方法,没有子节点的节点无法收起

This commit is contained in:
wanglin2 2023-10-15 16:46:08 +08:00
parent d1dcef2537
commit 1a3401fd1a

View File

@ -1230,7 +1230,7 @@ class Render {
this.renderTree, this.renderTree,
null, null,
(node, parent, isRoot) => { (node, parent, isRoot) => {
if (!isRoot) { if (!isRoot && (node.children && node.children.length > 0)) {
node.data.expand = false node.data.expand = false
} }
}, },
@ -1250,7 +1250,12 @@ class Render {
this.renderTree, this.renderTree,
null, null,
(node, parent, isRoot, layerIndex) => { (node, parent, isRoot, layerIndex) => {
node.data.expand = layerIndex < level const expand = layerIndex < level
if (expand) {
node.data.expand = true
} else if (!isRoot && (node.children && node.children.length > 0)) {
node.data.expand = false
}
}, },
null, null,
true, true,