// 注意:先把分页做好
data() {
return {
total: 1000, // 默认数据总数
pagesize:10,//每页的数据条数 - 当前显示数据条数
currentPage:1,//默认开始页面 - 当前页
}
}
// 关键代码:
// (当前页 - 1) * 当前显示数据条数 + 当前行数据的索引 + 1
// (page - 1) * pageSize + scope.$index + 1
方法一:
<el-table-column
type="index"
label="序号"
width="50">
<template slot-scope="scope">
<span v-text="getIndex(scope.$index)"></span>
</template>
</el-table-column>
methods: {
// 表格序列号
getIndex($index) {
console.log($index,"序号")
// 表格序号
// (当前页 - 1) * 当前显示数据条数 + 当前行数据的索引 + 1
return (this.currentPage-1)*this.pagesize + $index +1
}
}
方法二:改造后
<el-table-column
label="序号"
width="50"
align="center">
<template scope="scope">
<span>{{(currentPage - 1) * pagesize + scope.$index + 1}}</span>
</template>
</el-table-column>
element-ui的el-table中添加递增序号
猜你喜欢
转载自blog.csdn.net/miaozhenzhong/article/details/103872132
今日推荐
周排行