Skip to content

Commit 0d7900e

Browse files
committed
fix: table infinite update #2270
1 parent 1e86019 commit 0d7900e

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

components/table/Table.jsx

+4-2
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,9 @@ export default {
416416
data = data.slice(0);
417417
const sorterFn = this.getSorterFn(currentState);
418418
if (sorterFn) {
419-
data = this.recursiveSort(data, sorterFn);
419+
// 使用新数组,避免改变原数组导致无限循环更新
420+
// https://github.com/vueComponent/ant-design-vue/issues/2270
421+
data = this.recursiveSort([...data], sorterFn);
420422
}
421423
// 筛选
422424
if (filter && filters) {
@@ -885,7 +887,7 @@ export default {
885887
item[childrenColumnName]
886888
? {
887889
...item,
888-
[childrenColumnName]: this.recursiveSort(item[childrenColumnName], sorterFn),
890+
[childrenColumnName]: this.recursiveSort([...item[childrenColumnName]], sorterFn),
889891
}
890892
: item,
891893
);

0 commit comments

Comments
 (0)