首先定义序号
<el-table-column width="50" type="index":index="count" label="序号">
</el-table-column>
然后定义方法
data() {
return {
totalItems: 0, // 总数据条数
currentPage: 1, // 当前页码
pageSize: 10, // 每页条数
startIndex: 0 // 起始索引
};
},
methods: {
count(index) {
return this.startIndex + index + 1;
},
handleSizeChange(size) {
this.pageSize = size;
this.startIndex = (this.currentPage - 1) * this.pageSize;
},
handleCurrentChange(page) {
this.currentPage = page;
this.startIndex = (page - 1) * this.pageSize;
}
}