1.用户列表页面使用的rc-pagination分页组件
Github地址: https://github.com/react-component/pagination
2.安装
cnpm install --save-dev rc-pagination
3.引入
-
import React from 'react';
-
import RcPagination from 'rc-pagination';
-
import 'rc-pagination/dist/rc-pagination.min.css';
4.封装成组件,在util里边新建文件夹Pagination,里边新建 index.jsx
-
import React from 'react';
-
import RcPagination from 'rc-pagination';
-
import 'rc-pagination/dist/rc-pagination.min.css';
-
-
class Pagination extends React.Component{
-
constructor(props){
-
super(props);
-
}
-
render(){
-
return(
-
<div className="row">
-
<div className="col-md-12">
-
<RcPagination {...this.props}
-
hideOnSinglePage
-
showQuickJumper/>
-
</div>
-
</div>
-
);
-
}
-
}
5.使用, Pagination组件里边要传入两个参数,一是current 当前页,二是total总记录数, pageSize每一页的记录数量默认为10
-
import Pagination from 'util/pagination/index.jsx';
-
-
<Pagination current={this.state.pageNum}
-
total={this.state.total}
-
onChange={(pageNum) => {this.onPageNumChange(pageNum)}}/>
6.Pagination组件里边可以定义onchange事件, Function(current, pageSize) ,参数是当前页current和pageSizeme每页的记录数