class AppPagination extends React.Component { handleChange(pageNum) { this.props.handleChangePage(pageNum); } showTotalPage() { return `共 ${this.props.total} 条`; } render() { return ( <div> {this.props.total > 0 ? <Pagination defaultCurrent={1} showQuickJumper={true} total={this.props.total} pageSize={this.props.pageSize} showTotal={this.showTotalPage.bind(this)} onChange={this.handleChange.bind(this)} /> : null} </div> ) } } export default AppPagination;
使用:
<AppPagination total={this.state.totalElements} pageSize={this.state.size} handleChangePage={(pageNum) => this.handleChangePage(pageNum)} /> handleChangePage(pageNum){ initdata(pageNum) }