Pagination 分页器

定义/Definition

采用分页的形式分隔长列表

规则 / Rule

每次只加载一个页面

代码演示

按钮形态

基本的分页器。

  1. import { Pagination, WhiteSpace, Icon, WingBlank } from 'antd-mobile';
  2. let App = React.createClass({
  3. render() {
  4. return (
  5. <div className="loading-example">
  6. <div className="pagination-container" >
  7. <WhiteSpace size={20} />
  8. <WingBlank>
  9. <p className="title">按钮内带文本</p>
  10. <Pagination
  11. total={5}
  12. current={1}
  13. prevText="上一步"
  14. nextText="下一步"
  15. />
  16. </WingBlank>
  17. <WhiteSpace size={20} />
  18. <WingBlank>
  19. <p className="title">带文本和icon</p>
  20. <Pagination
  21. total={5}
  22. showNumber={false}
  23. current={1}
  24. simple
  25. prevText={<div><Icon type="left" />上一步</div>}
  26. nextText={<div>下一步<Icon type="right" /></div>}
  27. />
  28. </WingBlank>
  29. <WhiteSpace size={20} />
  30. <WingBlank>
  31. <p className="title">仅icon</p>
  32. <Pagination
  33. total={5}
  34. simple
  35. current={1}
  36. prevText={<Icon type="left" />}
  37. nextText={<Icon type="right" />}
  38. />
  39. </WingBlank>
  40. <WhiteSpace size={20} />
  41. <WingBlank>
  42. <p className="title">隐藏数字</p>
  43. <Pagination
  44. total={5}
  45. simple={false}
  46. current={1}
  47. prevText="上一步"
  48. nextText="下一步"
  49. />
  50. </WingBlank>
  51. <WhiteSpace size={20} />
  52. <WingBlank>
  53. <p className="title">小号</p>
  54. <Pagination
  55. total={5}
  56. size="small"
  57. activeIndex={1}
  58. />
  59. </WingBlank>
  60. <WhiteSpace size={20} />
  61. <WingBlank>
  62. <Pagination
  63. total={5}
  64. size="small"
  65. simple
  66. activeIndex={1}
  67. />
  68. </WingBlank>
  69. </div>
  70. </div>
  71. );
  72. },
  73. });
  74. ReactDOM.render(<App />, mountNode);
  1. .demo-preview-item .loading-example * {
  2. box-sizing: border-box;
  3. }
  4. .loading-example .title {
  5. margin-bottom: 20px;
  6. }

数字形态

基本的分页器。

  1. import { Pagination, WhiteSpace, WingBlank } from 'antd-mobile';
  2. let App = React.createClass({
  3. render() {
  4. return (
  5. <div>
  6. <div className="pagination-container" >
  7. <WhiteSpace size={20} />
  8. <WingBlank>
  9. <p className="title">只显示数字</p>
  10. <Pagination
  11. mode="number"
  12. total={5}
  13. activeIndex={2}
  14. />
  15. </WingBlank>
  16. <WhiteSpace size={20} />
  17. <WingBlank>
  18. <Pagination
  19. mode="number"
  20. size="small"
  21. total={5}
  22. activeIndex={-1}
  23. />
  24. </WingBlank>
  25. </div>
  26. </div>
  27. );
  28. },
  29. });
  30. ReactDOM.render(<App />, mountNode);
  1. .loading-example .title {
  2. margin-right: 20px;
  3. }

点状型

基本的分页器。

  1. import { Pagination, WhiteSpace, WingBlank } from 'antd-mobile';
  2. let App = React.createClass({
  3. render() {
  4. return (
  5. <div>
  6. <div className="pagination-container" >
  7. <WhiteSpace size={20} />
  8. <WingBlank>
  9. <p className="title">点状</p>
  10. <Pagination
  11. mode="pointer"
  12. size="large"
  13. total={5}
  14. activeIndex={1}
  15. />
  16. </WingBlank>
  17. <WhiteSpace size={20} />
  18. <WingBlank>
  19. <Pagination
  20. mode="pointer"
  21. size="small"
  22. total={5}
  23. activeIndex={2}
  24. />
  25. </WingBlank>
  26. </div>
  27. </div>
  28. );
  29. },
  30. });
  31. ReactDOM.render(<App />, mountNode);
  1. .loading-example .title {
  2. margin-right: 20px;
  3. }

Pagination分页器 - 图1

API

Pagination

参数说明类型可选值默认值
mode形态stringbutton or number or pointbutton
current当前索引number
total数据总数number0
simple是否显示数值booleantrue or falsetrue
size形态大小booleansmall or large''
disabled禁用状态booleantrue or falsefalse
prevTextprev文字string or React.ElementPrev
nextTextnext文字string or React.ElementNext
onChangechange事件触发的回调函数,参数是event对象function