diff --git a/simple-mind-map/src/core/render/node/Node.js b/simple-mind-map/src/core/render/node/Node.js index eaec8d8d..ffbc12b4 100644 --- a/simple-mind-map/src/core/render/node/Node.js +++ b/simple-mind-map/src/core/render/node/Node.js @@ -572,9 +572,10 @@ class Node { } this.updateNodeActiveClass() let { alwaysShowExpandBtn } = this.mindMap.opt + const childrenLength = this.nodeData.children.length if (alwaysShowExpandBtn) { // 需要移除展开收缩按钮 - if (this._expandBtn && this.nodeData.children.length <= 0) { + if (this._expandBtn && childrenLength <= 0) { this.removeExpandBtn() } else { // 更新展开收起按钮 @@ -583,7 +584,9 @@ class Node { } else { let { isActive, expand } = this.getData() // 展开状态且非激活状态,且当前鼠标不在它上面,才隐藏 - if (expand && !isActive && !this._isMouseenter) { + if (childrenLength <= 0) { + this.removeExpandBtn() + } else if (expand && !isActive && !this._isMouseenter) { this.hideExpandBtn() } else { this.showExpandBtn()