很简单
1、页面table引用这句,最重要
<el-table :data="msgList.slice((pageHelper.currentPageNum-1)*pageHelper.pageSize,pageHelper.currentPageNum*pageHelper.pageSize)"></el-table>
2、页面添加分页
<!--分页--> <div class="block" align="center" style="margin-top: 10px;width: 80%"> <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page.sync="pageHelper.currentPageNum" :page-sizes="pageHelper.pageSizeList" :page-size="pageHelper.pageSize" layout="total, sizes, prev, pager, next, jumper" :total="pageHelper.totalSize"> </el-pagination> </div>
3、添加js函数
handleSizeChange(val) { //console.log(`每页 ${val} 条`); this.pageHelper.pageSize = val; }, handleCurrentChange(val) { //console.log(`当前页: ${val}`); this.pageHelper.currentPageNum = val; },