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

[Bug Report] usePagination manual 为 true 时,defaultParams: [{ pageSize: 50 }] 无效 #40

Closed
Liu-Ya opened this issue Apr 28, 2021 · 6 comments

Comments

@Liu-Ya
Copy link

Liu-Ya commented Apr 28, 2021

Bug 描述 Bug description

manual: true 时设置的defaultParams: [{ pageSizeKey: 50 }]不生效,获取到的 pageSize 为10

代码重现 Reproduce

      const {
        current,
        total,
        loading,
        pageSize,
        changeCurrent,
        changePageSize,
        run: fetchData,
      } = usePagination(fetchOrderList, {
        // manual: true,
        defaultParams: [{ pageSize: 50, page: 1 }],
        pagination: { currentKey: 'page', pageSizeKey: 'pageSize', totalKey: 'total' },
        onSuccess: (res) => {
          gridOptions.value.api?.setRowData(res.data);
        },
      });

期望结果 Desired result

获得的 pageSize 默认为 50

其他信息 Other information

@github-actions
Copy link

Hello @Liu-Ya. Please provide a online reproduction by forking this link or a minimal GitHub repository. Make sure to choose the correct version.
你好 @Liu-Ya, 我们需要你提供一个在线的重现实例以便于我们帮你排查问题。你可以通过点击 此处 创建一个 codesandbox 或者提供一个最小化的 GitHub 仓库。请确保选择准确的版本。

@John60676
Copy link
Member

噢,好像是有点问题,我再看看

@John60676
Copy link
Member

defaultparams 只会在 manual: false 时生效。至于在 usePagination 中使用时,我觉得可以讨论一下

@Liu-Ya
Copy link
Author

Liu-Ya commented Apr 28, 2021

defaultparams 只会在 manual: false 时生效。至于在 usePagination 中使用时,我觉得可以讨论一下

确实不应该在 manual: true 时生效,我看调用 run 时也是要自己传入分页的,现在逻辑没错

usePaginationpagination 中添加一个配置项 如 defaultPageSizedefaultCurrent 应该是可以的,当manual: falsedefaultParamspagination.defaultPageSize 优先级高

John60676 added a commit that referenced this issue Apr 28, 2021
@John60676
Copy link
Member

下个版本修复

@John60676
Copy link
Member

已发布 v1.1.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants