index.js 676 B

123456789101112131415161718192021222324
  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 { current, total, onChange } = this.props;
  7. if (page < current || page > total) return;
  8. if (onChange) onChange(page);
  9. }
  10. render() {
  11. const { current, total } = this.props;
  12. return (
  13. <div className="user-pagination">
  14. <Icon name="arrow-left-small" onClick={() => this.onChangePage(current - 1)} />
  15. <span>
  16. <b>{current}</b>/{total}
  17. </span>
  18. <Icon name="arrow-right-small" onClick={() => this.onChangePage(current + 1)} />
  19. </div>
  20. );
  21. }
  22. }