- 第一种情况:一次只展示一个页面的数据,下一页的数据需要发送数据向后台获取。
<el-table>
表格
</el-table>
<el-pagination
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
:current-page.sync="curPage"
:page-sizes="[30,50,100,200]"
:page-size="pagesize"
layout="total, sizes, prev, pager, next, jumper"
:total="total"
></el-pagination>
handleSizeChange(size) {
this.pagesize = size;
this.getReceivable();
},
handleCurrentChange(pageNum) {
this.curPage = pageNum;
this.getReceivable();
}
- 第二种情况,一次性请求所有数据并分页,分页时毋需向后端请求数据
<el-table
:data="areaGroup.slice((curPage-1)*pagesize,curPage*pagesize)"
>
</el-table>
<el-pagination
:current-page.sync="curPage"
:page-sizes="[40,50,100,200]"
:page-size="pagesize"
layout="total, sizes, prev, pager, next, jumper"
:total="areaGroup.length"
></el-pagination>