Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Need Help]是否支持自定义请求接口时的分页参数 #216

Open
wyh369352887 opened this issue Sep 27, 2023 · 1 comment
Open
Labels
question Further information is requested

Comments

@wyh369352887
Copy link

问题描述 Problem Description

比如我的业务接口,currentKey和pageSizeKey外边还包着一层对象:

{
 "page": {
   "current": 1,
   "pageSize": 10,
  },
 "otherParams": {...}
}

是否只有开启manual,手动构建参数调用run这一条路可行?

其他信息 Other information

没有找到相关的issue,目前有2个思路都行不通:

  1. 提供的options中,有onBefore钩子,但在不改变参数params引用地址的情况下,修改无效,实际请求携带的还是入参时的样子
  2. 在defaultParams中传入了正确格式的ref对象,但发出请求的时候,usePagination自己添加的page参数页码是正确的,defaultParams中的page参数还是初始化的值。
const _pageNo = ref(1);
const _pageSize = ref(10);

const { data, current, totalPage, loading, pageSize, changeCurrent } =
  usePagination(listAction, {
    defaultParams: [
      {
        page: { pageNo: _pageNo.value, pageSize: _pageSize.value },
      },
    ],
    onSuccess: (data: any, params: any): any => {
      _pageNo.value = data.page.pageNo;
      _pageSize.value = data.page.pageSize;
    },
});
  
setInterval(() => {
  current.value++;
}, 2000);

实际请求的参数中,默认的current会发生变化,而page.pageNo永远是1

@wyh369352887 wyh369352887 added the question Further information is requested label Sep 27, 2023
@wyh369352887 wyh369352887 changed the title [Need Help] [Need Help]是否支持自定义分页器参数 Sep 27, 2023
@wyh369352887 wyh369352887 changed the title [Need Help]是否支持自定义分页器参数 [Need Help]是否支持自定义请求接口时的分页参数 Sep 27, 2023
@wyh369352887
Copy link
Author

或者currentKey和pageSizeKey使用lodash.set实现

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant