组件得编写

一个组件需要请求远程得参数,暴露出对应得promise函数

export type ProductList = {
  total: number;
  list:Array<{
    id:string;
    name:string;
  }>
}
export type RequestData = {
  pageInfo:{currentPage:number,pageSize:number},
  searchParams:{name:string,id:string}
}
export type AsyncProductList = ( pageInfo:{currentPage:number,pageSize:number},searchParams:{name:string,id:string})=>Promise<ProductList>
export type IComponentsProps = {
  //the service to get product list
  loadProduct: AsyncProductList
}
export function test111(data:RequestData){
  return Axios<ProductList>({
    url: `api/xxx`,
    method: 'get',
    ...data,
  })
}
posted @ 2023-05-22 11:31  zeal666  阅读(18)  评论(0)    收藏  举报