refactor: useTableToolbar 延迟挂载确保 toolbar 正确挂载

pull/97/head
puhui999 2025-05-09 16:57:03 +08:00
parent 8859ee5f29
commit 61dc7a45a1
1 changed files with 9 additions and 3 deletions

View File

@ -1,4 +1,4 @@
import type { VxeTableInstance } from '#/adapter/vxe-table';
import type { VxeTableInstance, VxeToolbarInstance } from '#/adapter/vxe-table';
import type { TableToolbar } from '#/components/table-toolbar';
import { ref, watch } from 'vue';
@ -14,8 +14,14 @@ export function useTableToolbar() {
const table = tableRef.value;
const tableToolbar = tableToolbarRef.value;
if (table && tableToolbar) {
await table.connect(tableToolbar.getToolbarRef()!);
isBound.value = true;
setTimeout(async () => {
const toolbar = tableToolbar.getToolbarRef();
if (!toolbar) {
console.error('[toolbar 挂载失败] Table toolbar not found');
}
await table.connect(toolbar as VxeToolbarInstance);
isBound.value = true;
}, 1000); // 延迟挂载确保 toolbar 正确挂载
}
}