index.js 747 B

12345678910111213141516171819202122232425
  1. import React, { Component } from 'react';
  2. import './index.less';
  3. import Icon from '../Icon';
  4. export default class extends Component {
  5. onChangePage(page) {
  6. const { total, pageSize, onChange } = this.props;
  7. const all = Math.ceil(total / pageSize);
  8. if (page <= 0 || page > all) return;
  9. if (onChange) onChange(page);
  10. }
  11. render() {
  12. const { current, total, pageSize } = this.props;
  13. return (
  14. <div className="user-pagination">
  15. <Icon name="arrow-left-small" onClick={() => this.onChangePage(current - 1)} />
  16. <span>
  17. <b>{current}</b>/{Math.ceil(total / pageSize)}
  18. </span>
  19. <Icon name="arrow-right-small" onClick={() => this.onChangePage(current + 1)} />
  20. </div>
  21. );
  22. }
  23. }