We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
我按照ant design 的示例:
<script lang="ts" setup> import type { TableProps } from 'ant-design-vue' import { getDemoTable } from '@/api/demo' const columns = [] const { data, run, loading, current, pageSize, total } = usePagination(getDemoTable, { pagination: { currentKey: 'ext.page', pageSizeKey: 'ext.size', totalKey: 'ext.total', }, }) const dataSource = computed(() => data.value?.list ?? []) const pagination = computed(() => ({ total: total.value, current: current.value, pageSize: pageSize.value, })) const onTableChange: TableProps['onChange'] = (pag, filters, sorter) => { run({ page: pag.current, size: pag.pageSize, sorter: sorter, ...filters, }) } </script> <template> <a-table :row-key="(record) => record.id" :columns="columns" :data-source="dataSource" :pagination="pagination" :loading="loading" @change="onTableChange" ></a-table> </template> <style scoped lang="scss"></style>
这是接口的返回结构:
我的疑惑: 初次时参数是这样的: 点击分页时是这样的:
我不太理解初次的传参为什么是这样
The text was updated successfully, but these errors were encountered:
currentKey 和 pageSizeKey 在你这个例子中应该填的是 'page' 和 'size',它们是 getDemoTable 请求函数的形参名
currentKey
pageSizeKey
getDemoTable
Sorry, something went wrong.
如果填 'page' 和 'size',就不匹配我的返回值了,值是在ext里的
匹配的是接口的入参,不是返回值
currentKey 和 pageSizeKey 是入参,返回值是totalKey和totalPageKey。 如果你放ext,应该是totalKey = data.data.ext.total totalPageKey以此类推。 pageno 和 size,不需要从你的接口返回去读的,这个是用的请求的参数+返回的total来进行计算的,确保分页能访问到响应体ext.total的字段即可。
感谢。文档我没看仔细,也是没想到pagination既有入参也有返回值
No branches or pull requests
问题描述 Problem Description
我按照ant design 的示例:
这是接口的返回结构:
我的疑惑:
初次时参数是这样的:
点击分页时是这样的:
我不太理解初次的传参为什么是这样
其他信息 Other information
The text was updated successfully, but these errors were encountered: