问题描述
实现分页的时候报错
相关代码
<el-pagination
background
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
:current-page="currentPage"
:page-sizes="[2, 20, 30, 50,100]"
:page-size="pagesize"
layout="total, sizes,prev, pager, next, jumper"
:total="tableData.length">
</el-pagination>
data() {
return {
total: 1000, //默认数据总数
pagesize: 4, //每页的数据条数
currentPage: 1, //默认开始页面
}
}
methods: {
async getList() {
this.paginationShow = false
let param = {
pageNo: this.currentPage, //第几页
pageSize: this.pagesize, //每页多少条
prohibit: 1
};
let res = await cdService.getAllData(param);
if (res) {
this.loading = false;
this.total = res.data.totalRecord;
this.tableData = res.data;
this.paginationShow = true;
console.log(res, "res1111111111111212121");
console.log(res.data.totalRecord, "res.data.totalRecord");
}
console.log(res.data, "res1111111111111");
},
handleSizeChange(val) {
console.log(`每页 ${val} 条`);
this.pageSize = val;
this.currentPage = 1;
this.getList();
},
handleCurrentChange(val) {
console.log(`当前页: ${val}`);
this.currentPage = val;
this.getList();
},
}
这个已解决,是因为之前参照网上的在:data=table后面绑定了

把table后面的删掉就可以了