Element Plus version
1.2.0-beta.5
OS/Browsers version
chrome 96.0.4664.110
Vue version
3.2.26
Reproduction Link
https://codepen.io/fashion01cc/pen/vYeJbRv
Steps to reproduce
- 表头部分通过v-for=“item in columns”生成并设置了key值
- 改变columns中的数据的顺序
- 表头顺序未发生改变
What is Expected?
表头顺序按照columns中顺序重新生成
What is actually happening?
保持原来的顺序
3条答案
按热度按时间yhuiod9q1#
我也碰到过类似的问题,你可以这样写来避免这种问题:
changeSort() {
this.columns = [];
setTimeout(() => {
this.columns = [{
label: 'B',
prop: 'b'
},
{
label: 'A',
prop: 'a'
},
{
label: 'C',
prop: 'c'
},
]
});
}
dxpyg8gm2#
我也碰到过类似的问题,你可以这样写来避免这种问题: changeSort() { this.columns = []; setTimeout(() => { this.columns = [{ label: 'B', prop: 'b' }, { label: 'A', prop: 'a' }, { label: 'C', prop: 'c' }, ] }); }
不设置key可以正常应用,但感觉这是个bug
xdnvmnnf3#
可以试试这个方式,感觉应该是Vue的问题