From 9a4beb010558aa96408b60a1963a487ff89263a7 Mon Sep 17 00:00:00 2001 From: justwiner <30335393+justwiner@users.noreply.github.com> Date: Wed, 20 Jan 2021 15:29:51 +0800 Subject: [PATCH] fix(table): when the data changes, the table does not update the layout (#1315) --- packages/table/src/store/watcher.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/table/src/store/watcher.ts b/packages/table/src/store/watcher.ts index ade7fa682a..c6289015bb 100644 --- a/packages/table/src/store/watcher.ts +++ b/packages/table/src/store/watcher.ts @@ -1,4 +1,4 @@ -import { ref, getCurrentInstance, unref } from 'vue' +import { ref, getCurrentInstance, unref, watch } from 'vue' import { getKeysMap, getRowIdentity, @@ -68,6 +68,15 @@ function useWatcher() { const sortOrder = ref(null) const hoverRow = ref(null) + + watch( + data, + () => instance.state && scheduleLayout(false), + { + deep: true, + }, + ) + // 检查 rowKey 是否存在 const assertRowKey = () => { if (!rowKey.value) throw new Error('[ElTable] prop row-key is required')