我已经使用react-bootstrap-table中的BootstrapTable实现了带有分页的表,并从外部API获取数据。每次将收到10件物品。因此,pageSize是10,但是我从API得到了totalPages变量,比方说5。不幸的是,表数据每次都是10,所以只有一页
https://codesandbox.io/s/zealous-archimedes-tbcy9?file=/src/Tablepagination.js:732-923
出于输出目的,使用示例产品代替了外部api
答案 0 :(得分:0)
const lastIndex = this.state.currentPage * this.state.detailsperpage;
const firstIndex = lastIndex - this.state.detailsperpage;
const currentDetails = this.state.details.slice(firstIndex,lastIndex);
const totalpages = Math.ceil(this.state.details.length / this.state.detailsperpage)
将状态设置为currentpage = 1,detailsperpage = 10并在jsx中映射currentDetails希望这会有所帮助.. !!