要在 ProTable 组件中自动显示行数,你可以使用 pagination 属性并将 showSizeChanger 属性设置为 true。这将在表格的底部显示一个分页器,并允许用户选择每页显示的行数。

以下是一个示例代码:

import { ProTable } from '@ant-design/pro-table';

const dataSource = [
  {
    id: 1,
    name: 'John Doe',
    age: 25,
  },
  // ...其他数据
];

const columns = [
  {
    title: 'ID',
    dataIndex: 'id',
  },
  {
    title: 'Name',
    dataIndex: 'name',
  },
  {
    title: 'Age',
    dataIndex: 'age',
  },
  // ...其他列
];

const ExampleTable = () => {
  return (
    <ProTable
      dataSource={dataSource}
      columns={columns}
      pagination={{
        showSizeChanger: true,
      }}
    />
  );
};

export default ExampleTable;

这样,表格将自动显示行数并提供一个下拉列表,允许用户选择每页显示的行数。


原文地址: https://www.cveoy.top/t/topic/pkVa 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录