Skip to content

The new node added by the append method after the [Bug Report] tree control lazily loads the node from the database makes the other sibling children disappear #12235

@fosin

Description

@fosin

Element UI version

2.4.5

OS/Browsers version

windows10 chrome 67

Vue version

2.5.17

Reproduction Link

https://jsfiddle.net/28860823/mmx38qxw/4619/

Steps to reproduce

是通过数据库懒加载的数据才会有这个问题,所以问题无法通过这个地址重现,上面重现地址是没有问题的,描述一下问题:
tree控件懒加载模式下,通过数据库懒加载出来的节点,通过append方法增加的子节点会把其他子节点搞消失了,调试发现节点数据data.children都是空的,当通过append添加节点后,data.children确实有刚添加的节点的数据,但是其他同级节点就不会在界面上消失了。

原因分析:tree控件会优先从data.children中加载节点,其次才会从childNodes中加载节点,那么当我们append节点后手动将data.children置空即可

临时解决方案:
const pNode = this.$refs.organizTree.getNode(this.form.pId)
this.$refs.organizTree.append(response.data.data, pNode)
// 以下代码启用后可以解决tree控件bug(会导致原有子节点丢失问题)
pNode.data.children = null

What is Expected?

正常情况append增加的子节点应该排在其他子节点之后,而不是只剩下增加的子节点

What is actually happening?

tree控件从数据库懒加载节点后通过append方法增加的新节点会把其他同级子节点搞消失

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions