Skip to content

Commit

Permalink
fix(table): reload in useTable not support await
Browse files Browse the repository at this point in the history
修复useTable返回的reload方法不支持使用await等待加载完毕的问题
  • Loading branch information
mynetfan committed Sep 16, 2021
1 parent e85649b commit 7b6d5e4
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
- **BasicTable**
- 修复可编辑单元格某些情况下无法提交的问题
- 修复`inset`属性不起作用的问题
- 修复`useTable``BasicTable`实例的`reload`方法`await`表现不一致的问题
- **BasicModal**
- 修复点击遮罩、按下`Esc`键都不能关闭`Modal`的问题
- 修复点击关闭按钮、最大化按钮旁边的空白区域也会导致`Modal`关闭的问题
Expand Down
5 changes: 3 additions & 2 deletions src/components/Table/src/hooks/useDataSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ export function useDataSource(
setPagination({
current: currentTotalPage,
});
fetch(opt);
return await fetch(opt);
}
}

Expand All @@ -295,6 +295,7 @@ export function useDataSource(
items: unref(resultItems),
total: resultTotal,
});
return resultItems;
} catch (error) {
emit('fetch-error', error);
dataSourceRef.value = [];
Expand All @@ -319,7 +320,7 @@ export function useDataSource(
}

async function reload(opt?: FetchParams) {
await fetch(opt);
return await fetch(opt);
}

onMounted(() => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/Table/src/hooks/useTable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export function useTable(tableProps?: Props): [
getForm: () => FormActionType;
} = {
reload: async (opt?: FetchParams) => {
getTableInstance().reload(opt);
return await getTableInstance().reload(opt);
},
setProps: (props: Partial<BasicTableProps>) => {
getTableInstance().setProps(props);
Expand Down

0 comments on commit 7b6d5e4

Please sign in to comment.