<!-- 分页 -->
<el-pagination
:pager-count="5"
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
:current-page="pageNum"
:page-sizes="[10, 30, 50, 100]"
:page-size="pageSize"
layout="sizes, prev, pager, next,total"
:total="total"
style="margin: 10px 0px"
>
</el-pagination>
// 分页
data(){
pageNum: 1,
pageSize: 10,
total: 0,
}
// 获取全部数据
getTableData() {
this.loading = true
taskSelect({ pageNum: this.pageNum, pageSize: this.pageSize }).then(
(res) => {
console.log(res)
this.loading = false
this.total = res.data.total
this.listData = res.data.list
}
)
},
// 分页
handleSizeChange(val) {
console.log(`每页 ${val} 条`)
this.pageSize = val
this.getTableData()
},
handleCurrentChange(val) {
console.log(`当前页: ${val}`)
this.pageNum = val
this.getTableData()
},
可以在这里获取全部数据
beforeCreate() {
this.getTableData()
}, //生命周期 - 创建之前