2016-03-31 14:17:09 +08:00
|
|
|
---
|
|
|
|
category: Components
|
2016-09-21 11:28:38 +08:00
|
|
|
subtitle: 分页
|
2022-11-09 12:28:04 +08:00
|
|
|
group: 导航
|
2016-09-21 11:28:38 +08:00
|
|
|
title: Pagination
|
2022-11-30 20:14:41 +08:00
|
|
|
cover: https://mdn.alipayobjects.com/huamei_7uahnr/afts/img/A*8y_iTJGY_aUAAAAAAAAAAAAADrJ8AQ/original
|
2023-02-09 22:17:31 +08:00
|
|
|
coverDark: https://mdn.alipayobjects.com/huamei_7uahnr/afts/img/A*WM86SrBC8TsAAAAAAAAAAAAADrJ8AQ/original
|
2016-03-31 14:17:09 +08:00
|
|
|
---
|
2015-06-15 22:01:39 +08:00
|
|
|
|
2015-06-26 14:42:30 +08:00
|
|
|
采用分页的形式分隔长列表,每次只加载一个页面。
|
2015-06-15 22:01:39 +08:00
|
|
|
|
2015-06-26 14:42:30 +08:00
|
|
|
## 何时使用
|
2015-06-17 20:24:42 +08:00
|
|
|
|
2015-06-26 14:42:30 +08:00
|
|
|
- 当加载/渲染所有数据将花费很多时间时;
|
|
|
|
- 可切换页码浏览数据。
|
2015-07-13 17:51:28 +08:00
|
|
|
|
2022-11-09 12:28:04 +08:00
|
|
|
## 代码演示
|
|
|
|
|
2022-11-17 17:31:26 +08:00
|
|
|
<!-- prettier-ignore -->
|
2022-11-09 12:28:04 +08:00
|
|
|
<code src="./demo/basic.tsx">基本</code>
|
|
|
|
<code src="./demo/more.tsx">更多</code>
|
|
|
|
<code src="./demo/changer.tsx">改变</code>
|
|
|
|
<code src="./demo/jump.tsx">跳转</code>
|
|
|
|
<code src="./demo/mini.tsx">迷你</code>
|
|
|
|
<code src="./demo/simple.tsx">简洁</code>
|
|
|
|
<code src="./demo/controlled.tsx">受控</code>
|
|
|
|
<code src="./demo/total.tsx">总数</code>
|
|
|
|
<code src="./demo/all.tsx">全部展示</code>
|
|
|
|
<code src="./demo/itemRender.tsx">上一步和下一步</code>
|
2022-12-06 23:14:30 +08:00
|
|
|
<code src="./demo/wireframe.tsx" debug>线框风格</code>
|
2022-11-09 12:28:04 +08:00
|
|
|
|
2015-07-13 17:51:28 +08:00
|
|
|
## API
|
|
|
|
|
2019-12-26 14:37:39 +08:00
|
|
|
```jsx
|
|
|
|
<Pagination onChange={onChange} total={50} />
|
2015-09-23 14:13:31 +08:00
|
|
|
```
|
2015-07-13 17:51:28 +08:00
|
|
|
|
2019-05-10 15:38:35 +08:00
|
|
|
| 参数 | 说明 | 类型 | 默认值 | 版本 |
|
|
|
|
| --- | --- | --- | --- | --- |
|
|
|
|
| current | 当前页数 | number | - | |
|
|
|
|
| defaultCurrent | 默认的当前页数 | number | 1 | |
|
|
|
|
| defaultPageSize | 默认的每页条数 | number | 10 | |
|
2019-11-22 10:33:34 +08:00
|
|
|
| disabled | 禁用分页 | boolean | - | |
|
|
|
|
| hideOnSinglePage | 只有一页时是否隐藏分页器 | boolean | false | |
|
2019-05-10 15:38:35 +08:00
|
|
|
| itemRender | 用于自定义页码的结构,可用于优化 SEO | (page, type: 'page' \| 'prev' \| 'next', originalElement) => React.ReactNode | - | |
|
|
|
|
| pageSize | 每页条数 | number | - | |
|
2023-02-28 10:56:06 +08:00
|
|
|
| pageSizeOptions | 指定每页可以显示多少条 | string\[] \| number\[] | \[`10`, `20`, `50`, `100`] | |
|
2020-10-21 10:33:43 +08:00
|
|
|
| responsive | 当 size 未指定时,根据屏幕宽度自动调整尺寸 | boolean | - | |
|
2020-01-17 18:23:58 +08:00
|
|
|
| showLessItems | 是否显示较少页面内容 | boolean | false | |
|
2020-06-30 13:26:37 +08:00
|
|
|
| showQuickJumper | 是否可以快速跳转至某页 | boolean \| { goButton: ReactNode } | false | |
|
2020-07-10 15:18:40 +08:00
|
|
|
| showSizeChanger | 是否展示 `pageSize` 切换器,当 `total` 大于 50 时默认为 true | boolean | - | |
|
2020-04-11 16:36:12 +08:00
|
|
|
| showTitle | 是否显示原生 tooltip 页码提示 | boolean | true | |
|
2020-06-30 13:26:37 +08:00
|
|
|
| showTotal | 用于显示数据总量和当前数据顺序 | function(total, range) | - | |
|
2019-05-10 15:38:35 +08:00
|
|
|
| simple | 当添加该属性时,显示为简单分页 | boolean | - | |
|
2020-06-30 13:26:37 +08:00
|
|
|
| size | 当为 `small` 时,是小尺寸分页 | `default` \| `small` | `default` | |
|
2019-05-10 15:38:35 +08:00
|
|
|
| total | 数据总数 | number | 0 | |
|
2021-04-18 13:43:59 +08:00
|
|
|
| onChange | 页码或 `pageSize` 改变的回调,参数是改变后的页码及每页条数 | function(page, pageSize) | - | |
|
2020-06-30 13:26:37 +08:00
|
|
|
| onShowSizeChange | pageSize 变化的回调 | function(current, size) | - | |
|