From 61dc7a45a1d953fc42e47c92b5e1a22b25333143 Mon Sep 17 00:00:00 2001 From: puhui999 Date: Fri, 9 May 2025 16:57:03 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20useTableToolbar=20=E5=BB=B6?= =?UTF-8?q?=E8=BF=9F=E6=8C=82=E8=BD=BD=E7=A1=AE=E4=BF=9D=20toolbar=20?= =?UTF-8?q?=E6=AD=A3=E7=A1=AE=E6=8C=82=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/web-antd/src/hooks/use-table-toolbar.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/apps/web-antd/src/hooks/use-table-toolbar.ts b/apps/web-antd/src/hooks/use-table-toolbar.ts index c8fd01a2..e4d16a61 100644 --- a/apps/web-antd/src/hooks/use-table-toolbar.ts +++ b/apps/web-antd/src/hooks/use-table-toolbar.ts @@ -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 正确挂载 } }