<el-pagination
layout="total, sizes, prev, pager, next, jumper"
:page-sizes="[10, 20, 30, 40]"
:total="pagination.total"
:current-page="pagination.pageNum"
:page-size="pagination.pageSize"
@size-change="pageSizeChange"
@current-change="pageNumChange"
/>
data() {
return {
pagination: {
total: 100,
pageNum: 1,
pageSize: 10,
},
};
},
methods: {
//显示条数发生变化触发该事件
pageSizeChange(newSize) {
this.pagination.pageSize = newSize;
this.getList();
},
//页码发生变化触发该事件
pageNumChange(newPage) {
this.pagination.pageNum = newPage;
this.getList();
},
},
mounted() {
const pagination__total = document.querySelector(
".el-pagination__total"
);
pagination__total.innerText = `总共 ${this.pagination.total} 组数据`;
},