Element: [Bug Report] elementUI 2.4.6 version can not delete tree nodes.

Created on 7 Sep 2018  ·  15Comments  ·  Source: ElemeFE/element

Element UI version

2.4.6

OS/Browsers version

window7旗舰版

Vue version

2.5.16

Reproduction Link

https://jsfiddle.net/mmx38qxw/

Steps to reproduce

就在官网提供的API上,点击删除,不能正常的删除节点
这个就是重现的链接:
http://element-cn.eleme.io/2.4/#/zh-CN/component/tree#zi-ding-yi-jie-dian-nei-rong
上面个重现链接是不正确的,这个重新啊链接才是争取的

What is Expected?

点击删除,可以正常的删除树形节点

What is actually happening?

点击删除,不可以正常的删除树形节点

Most helpful comment

try to change const children = parent.data.children || parent.data; to const children = parent.childNodes; in remove function

All 15 comments

Translation of this issue:

Element UI version
2.4.6

OS/Browsers version
Window7 ultimate

Vue version
2.5.16

Reproduction Link
https://jsfiddle.net/mmx38qxw/

Steps to reproduce
On the API provided by the official website, click delete, can not delete nodes normally.

This is the link to reproduce.
Http://element-cn.eleme.io/2.4/#/zh-CN/component/tree#zi-ding-yi-jie-dian-nei-rong

The above link is not correct.
What is Expected?

Click Delete to delete tree nodes normally.
What is actually happening?

Click Delete to delete tree nodes.

try to change const children = parent.data.children || parent.data; to const children = parent.childNodes; in remove function

现在问题已经解决了,,,就是按照上面那位大神说的,,,多谢!!!

没看懂啥意思呢......

仔细注意一下vue和elementUI的版本,,,elementUI2.4.6这个版本中,官网API提供的删除树形节点的remove方法不起作用,,,,就是这个意思....

哇!!这么快就回了 好感动!!!
我没用官方提供remove
我是直接操作tree的数据源,
操作数据源做添加操作的时,tree视图会正常刷新显示,
但是在数据源做删除操作时,tree视图没有刷新,没有一点反应

现在elementUI2.4.6官网的API提供的删除树形节点的方法:确实不能通过那样子的方法进行删除,用1楼的那个大神提供的方法就能够删除了,,,,我现在树形节点的删除问题已经解决了....

哇 又是这么快回复 巨感动~!第一次用github有人回复!!
但是他这个代码没怎么看懂......
可以加个微信或者QQ交流蛮?

const parent = node.parent; const children = parent.childNodes; const index = children.findIndex(d => d.id == data.id); children.splice(index, 1);
直接把删除节点的remove方法替换成上面的代码就可以了.....

我用的就是这个方法,在splice做删除的时候视图不更新,做添加时候视图就更新,很奇怪

注意一下vue的版本,和elementUI的版本
Element UI version2.4.6
Vue version2.5.16
要满足这两个版本,上面我说的那个方法才有效果的

深感无奈。。。溺了两天了这问题,
还是不行,版本换了后。。。
用谷歌插件vuetool查看了tree的computed,
image
做数据源增加时候,children和treeItemArray都在更改,
做数据源删除的时候,只有children在变,treeItemArray没变,
现在我这个截图,就是添加后再删除的操作,按理说children和treeItemArray数量应该一样的,
结果现在children只有6个,
treeItemArray是18个,
删除操作后整个视图一点动静都没有......

2.4.6 版本才会有该问题。
在修复 tree 的 issue 的时候,优化一些代码时候出的锅。本周会发一个新版本,请继续关注 ElementUI。
安装 ElementUI 时候,可以指定版本号来避免该问题。

npm i [email protected]

官方大佬,到底有没有比较实在的解决方案诶?起初本来就是2.4.5,然后换成2.4.6,现在又换回2.4.5,还是一样得.....

我现在用的就是2.4.6用最上面的那个大佬的方法已经把问题解决了...不用来回切换的....没有那么麻烦的....

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Zhao-github picture Zhao-github  ·  3Comments

Kingwl picture Kingwl  ·  3Comments

yuchonghua picture yuchonghua  ·  3Comments

yubo111 picture yubo111  ·  3Comments

zhguokai picture zhguokai  ·  3Comments