Interface UseTableList<T, P, D>

interface UseTableList<T, P, D> {
    request: {
        api: ((params) => Promise<T>);
        handleParams?: ((params) => P);
        pageNumKey?: string;
        pageSizeKey?: string;
        params?: P;
        watcher?: Watcher<P>;
    };
    response?: {
        append?: boolean;
        hasPage?: ((res) => boolean);
        listKey?: string;
        responseHandler?: ((res) => any);
        totalKey?: string;
    };
}

Type Parameters

  • T = any
  • P = any
  • D = any

Properties

Properties

request: {
    api: ((params) => Promise<T>);
    handleParams?: ((params) => P);
    pageNumKey?: string;
    pageSizeKey?: string;
    params?: P;
    watcher?: Watcher<P>;
}

Type declaration

  • api: ((params) => Promise<T>)

    请求方法

      • (params): Promise<T>
      • Parameters

        • params: P

        Returns Promise<T>

  • Optional handleParams?: ((params) => P)

    接口请求前处理

      • (params): P
      • Parameters

        • params: P

        Returns P

  • Optional pageNumKey?: string

    分页键

    Default

    pageNum
    
  • Optional pageSizeKey?: string

    分页键

    Default

    pageSize
    
  • Optional params?: P

    请求参数

  • Optional watcher?: Watcher<P>

    观察 默认监听pageNumKey,pageSizeKe变化触发请求 如果传入空数组,不监听

response?: {
    append?: boolean;
    hasPage?: ((res) => boolean);
    listKey?: string;
    responseHandler?: ((res) => any);
    totalKey?: string;
}

响应数据处理

Type declaration

  • Optional append?: boolean

    是否追加,主要用于滚动分页

  • Optional hasPage?: ((res) => boolean)

    处理是还有数据

      • (res): boolean
      • Parameters

        • res: D

        Returns boolean

  • Optional listKey?: string

    返回结果的数据列表键

    Default

    list
    

    Example

    // 响应数据为 { data: { list: [] } } 则传递 data.list;
    
  • Optional responseHandler?: ((res) => any)

    自定义响应时处理,返回值必须包含listKey,totalKey,如果为空,应返回对应的默认值,即list、total

      • (res): any
      • Parameters

        • res: D

        Returns any

  • Optional totalKey?: string

    返回结果的数据列表键

    Default

    total

    // 响应数据为 { data: { list: [], total: 0 } } 则传递 data.total;