From 7a499bf40f9fcaef46de6dc9e6a04aea3aa09790 Mon Sep 17 00:00:00 2001 From: btea <2356281422@qq.com> Date: Wed, 25 Jun 2025 22:39:32 +0800 Subject: [PATCH] refactor(components): [table] compatible with rowKey non-existence (#21134) * refactor(components): [table] compatible with rowKey non-existence * chore: update * fix: update --- packages/components/table/src/store/tree.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/components/table/src/store/tree.ts b/packages/components/table/src/store/tree.ts index 12097d4656..276d4bf2f6 100644 --- a/packages/components/table/src/store/tree.ts +++ b/packages/components/table/src/store/tree.ts @@ -77,8 +77,7 @@ function useTree(watcherData: WatcherPropsData) { const nested = normalizedData.value const normalizedLazyNode_ = normalizedLazyNode.value const newTreeData = {} - if (nested.size) { - const keys = Array.from(nested.keys()) + if (nested instanceof Map && nested.size) { const oldTreeData = unref(treeData) const rootLazyRowKeys = [] const getExpanded = (oldValue, key) => { @@ -96,7 +95,7 @@ function useTree(watcherData: WatcherPropsData) { } } // 合并 expanded 与 display,确保数据刷新后,状态不变 - keys.forEach((key) => { + nested.forEach((_, key) => { const oldValue = oldTreeData[key] const newValue = { ...nested.get(key) } newValue.expanded = getExpanded(oldValue, key)