<template>
<div id="app">
<el-table
:data="tableData.slice((currentPage-1)*size,currentPage*size)">
<el-table-column prop="date" label="日期"></el-table-column>
</el-table>
<!-- <span class="demonstration">完整功能</span> -->
<el-pagination
:current-page="currentPage"
:page-size="size"
layout="total, sizes, prev, pager, next, jumper"
:total="tableData.length">
</el-pagination>
</div>
</div>
</template>
data() {
return {
currentPage:1,
size:5,
tableData: [ // 若干条数据
{
date: '2016-05-02',
name: '王小虎',
address: '上海市普陀区金沙江路 1518 弄'
}]
}
}
使用数组的slice方法,截取数组,每次点击下一页实现翻页效果。
tableData.slice((currentPage-1)*size,currentPage*size)