Skip to content

[Need Help] 关于 usePagination的疑问 #240

Closed
@like0413

Description

@like0413

问题描述 Problem Description

我按照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>

这是接口的返回结构:
image

我的疑惑:
初次时参数是这样的:
image
点击分页时是这样的:
image

我不太理解初次的传参为什么是这样

其他信息 Other information

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions