import React, { Component } from 'react'; import './index.less'; import Icon from '../Icon'; export default class extends Component { onChangePage(page) { const { total, pageSize, onChange } = this.props; const all = Math.ceil(total / pageSize); if (page <= 0 || page > all) return; if (onChange) onChange(page); } render() { const { current, total, pageSize } = this.props; return ( <div className="user-pagination"> <Icon name="arrow-left-small" onClick={() => this.onChangePage(current - 1)} /> <span> <b>{current}</b>/{Math.ceil(total / pageSize)} </span> <Icon name="arrow-right-small" onClick={() => this.onChangePage(current + 1)} /> </div> ); } }