<el-pagination
layout="total,prev, pager, next,jumper"
:page-size="pagination.pageSize"
:current-page="pagination.pageNum"
@prev-click="prevClick"
@next-click="nextClick"
@current-change="currentChange"
:total="pagination.total"
></el-pagination>
data() {
return {
pagination: {
pageNum: 1,
pageSize: 9, //9个分页,后端写死了
total: 0,
},
}
},
prevClick() {
console.log('--------> 上一页的点击 <--------')
this.pagination.pageNum--
this.getNewsList()
},
nextClick() {
console.log('---------> 下一页点击 <-------')
this.pagination.pageNum++
this.getNewsList()
},
currentChange(e) {
this.pagination.pageNum = e
this.getNewsList()
},
getNewsList() {
this.$api
.newsList({
p: this.pagination.pageNum,
cid: this.cid,
})
.then((res) => {
this.cateInfo = res.data.cateInfo
this.dataList = res.data.dataList
this.pagination.total = res.data.dataCount
})
.catch((err) => {
console.log(err)
})
},