ElemeFE / element

A Vue.js 2.0 UI Toolkit for Web
https://element.eleme.io/
MIT License
54.1k stars 14.64k forks source link

The [Bug Report] V-for generated el-table-column changes the order of the array to try not to trigger the update, and div is available #9518

Closed javaswing closed 6 years ago

javaswing commented 6 years ago

Element UI version

1.4.13

OS/Browsers version

all brower

Vue version

2.1.10

Reproduction Link

https://jsfiddle.net/javaSwing/12v7bhhu/

Steps to reproduce

https://jsfiddle.net/javaSwing/12v7bhhu/

What is Expected?

数组改变顺序后,试图能进行对应的改变

What is actually happening?

无论怎么改变数据的顺序,sort,reverse之后,视图都没有改变

element-bot commented 6 years ago

Translation of this issue:

Element UI version

1.4.13

OS/Browsers version

All Brower

Vue version

2.1.10

Reproduction Link

https://jsfiddle.net/javaSwing/12v7bhhu/

Steps to reproduce

Https://jsfiddle.net/javaSwing/12v7bhhu/

What is Expected?

After the array changes the order, it tries to make a corresponding change

What is actually happening?

No matter how the order of the data is changed, sort, reverse, the view has not changed

Leopoldthecoder commented 6 years ago

https://jsfiddle.net/leopoldthecuber/12v7bhhu/2/ key 给错了。对于每一列,在 reverse 前后的 item.id 是一样的,不会触发渲染。

javaswing commented 6 years ago

@Leopoldthecoder 如果给的是index我对应列的formatter方法会,在原来列的位置起作用,比如我第3列是格式化money显示的,把他换到第8列,新的第3列会调用原来的formatter 请麻烦看下,我问了很多人也没有办法: https://jsfiddle.net/javaSwing/qyks3qfm/2/#

Leopoldthecoder commented 6 years ago

这样的话 key 需要满足两个条件:

一个可能的解决方法是:https://jsfiddle.net/leopoldthecuber/qyks3qfm/6/

javaswing commented 6 years ago

@Leopoldthecoder 非常感谢大佬的回答!