diff --git a/src/components/Table/src/hooks/useDataSource.ts b/src/components/Table/src/hooks/useDataSource.ts index 4cd2e98..a588f17 100644 --- a/src/components/Table/src/hooks/useDataSource.ts +++ b/src/components/Table/src/hooks/useDataSource.ts @@ -88,10 +88,7 @@ export function useDataSource( let resultInfo = res[listField] ? res[listField] : []; if (afterRequest && isFunction(afterRequest)) { // can modify the data returned by the interface for processing - resultInfo = (await afterRequest(resultInfo)); - if (!isArray(resultInfo)) { - resultInfo = [] - } + resultInfo = (await afterRequest(resultInfo)) || resultInfo; } dataSourceRef.value = resultInfo; setPagination({ diff --git a/src/components/Table/src/props.ts b/src/components/Table/src/props.ts index ee263b2..10c0e1e 100644 --- a/src/components/Table/src/props.ts +++ b/src/components/Table/src/props.ts @@ -25,17 +25,25 @@ export const basicProps = { default: () => [], required: true, }, + beforeRequest: { + type: Function as PropType<(...arg: any[]) => void | Promise>, + default: null, + }, request: { type: Function as PropType<(...arg: any[]) => Promise>, default: null, }, + afterRequest: { + type: Function as PropType<(...arg: any[]) => void | Promise>, + default: null, + }, rowKey: { type: [String, Function] as PropType string)>, default: undefined, }, pagination: { type: [Object, Boolean], - default: () => {}, + default: () => { }, }, //废弃 showPagination: { diff --git a/src/utils/is/index.ts b/src/utils/is/index.ts index fb1f3ed..088c6e8 100644 --- a/src/utils/is/index.ts +++ b/src/utils/is/index.ts @@ -11,7 +11,7 @@ export function is(val: unknown, type: string) { * @description: 是否为函数 */ export function isFunction(val: unknown): val is T { - return is(val, 'Function'); + return is(val, 'Function') || is(val, 'AsyncFunction'); } /**