From 749ba5c1daf459625518937c239787b756c0a780 Mon Sep 17 00:00:00 2001 From: SUPER_AI <1095705440@qq.com> Date: Tue, 29 Jun 2021 23:53:10 +0800 Subject: [PATCH] feat(table): support asynchrony in beforeFetch and afterFetch (#827) --- src/components/Table/src/hooks/useDataSource.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/Table/src/hooks/useDataSource.ts b/src/components/Table/src/hooks/useDataSource.ts index 7c8d887e..690bc6d0 100644 --- a/src/components/Table/src/hooks/useDataSource.ts +++ b/src/components/Table/src/hooks/useDataSource.ts @@ -203,7 +203,7 @@ export function useDataSource( ...(opt?.filterInfo ?? {}), }; if (beforeFetch && isFunction(beforeFetch)) { - params = beforeFetch(params) || params; + params = (await beforeFetch(params)) || params; } const res = await api(params); @@ -225,7 +225,7 @@ export function useDataSource( } if (afterFetch && isFunction(afterFetch)) { - resultItems = afterFetch(resultItems) || resultItems; + resultItems = (await afterFetch(resultItems)) || resultItems; } dataSourceRef.value = resultItems; setPagination({ -- GitLab