请找到我为分页尝试过的以下代码。我有 50 条记录,但我无法显示超过 10 条记录。而且我不知道迭代到接下来的 10 条记录直到 50 条记录。
render() {
const per_page=10;
const pages = Math.ceil(this.props.items.length / per_page);
const current_page = 1;
const start_offset = (current_page - 1) * per_page;
let start_count =0;
return (<tbody>{ this.props.items
.sort((a, b) => moment(b.order_date) - moment(a.order_date) || b.order_number - a.order_number)
.map((item, index) => {
if (index >= start_offset && start_count < per_page) {
start_count++;
return <SearchResultsItem key={item.id} item={item} open={this.props.open} />;
}
})
}
<Pagination
className="items-pagination pull-right"
bsSize="medium"
maxButton={10}
first last next prev boundaryLinks
item={pages}
activePage={current_page} />
</tbody>
);
}