fix(table): when the data changes, the table does not update the layout (#1315)

This commit is contained in:
justwiner 2021-01-20 15:29:51 +08:00 committed by GitHub
parent b85758912a
commit 9a4beb0105
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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')