Commit 7b6d5e44a9fe9ad9fcf1487fc6282ff194d0981d
1 parent
e85649bd
fix(table): `reload` in useTable not support await
修复useTable返回的reload方法不支持使用await等待加载完毕的问题
Showing
3 changed files
with
5 additions
and
3 deletions
CHANGELOG.zh_CN.md
src/components/Table/src/hooks/useDataSource.ts
... | ... | @@ -275,7 +275,7 @@ export function useDataSource( |
275 | 275 | setPagination({ |
276 | 276 | current: currentTotalPage, |
277 | 277 | }); |
278 | - fetch(opt); | |
278 | + return await fetch(opt); | |
279 | 279 | } |
280 | 280 | } |
281 | 281 | |
... | ... | @@ -295,6 +295,7 @@ export function useDataSource( |
295 | 295 | items: unref(resultItems), |
296 | 296 | total: resultTotal, |
297 | 297 | }); |
298 | + return resultItems; | |
298 | 299 | } catch (error) { |
299 | 300 | emit('fetch-error', error); |
300 | 301 | dataSourceRef.value = []; |
... | ... | @@ -319,7 +320,7 @@ export function useDataSource( |
319 | 320 | } |
320 | 321 | |
321 | 322 | async function reload(opt?: FetchParams) { |
322 | - await fetch(opt); | |
323 | + return await fetch(opt); | |
323 | 324 | } |
324 | 325 | |
325 | 326 | onMounted(() => { | ... | ... |
src/components/Table/src/hooks/useTable.ts
... | ... | @@ -68,7 +68,7 @@ export function useTable(tableProps?: Props): [ |
68 | 68 | getForm: () => FormActionType; |
69 | 69 | } = { |
70 | 70 | reload: async (opt?: FetchParams) => { |
71 | - getTableInstance().reload(opt); | |
71 | + return await getTableInstance().reload(opt); | |
72 | 72 | }, |
73 | 73 | setProps: (props: Partial<BasicTableProps>) => { |
74 | 74 | getTableInstance().setProps(props); | ... | ... |