element ui 實現table序號遞增:
(page - 1) * pageSize + scope.$index + 1 // (當前頁 - 1) * 當前顯示數據條數 + 當前行數據的索引 + 1
scope.$index獲取當前頁的當前行的索引號,一般都是從0開始,與本頁的實際行號差1,所以需要加1操作。還要考慮到頁碼所以需要加上(pageIndex - 1) * pagesize, 這樣 table 添加的序號就不會每頁都重從1開始了。
應用:
<el-table-column
label="序號"
type="index"
width="40"
align="center">
<template slot-scope="scope">
<span>{{(page - 1) * pageSize + scope.$index + 1}}</span>
</template>
</el-table-column>
element ui 實現table序號遞減:
{{total - ((currentPage-1)*pageSize) - scope.$index}} // 總條數 - (當前頁 - 1) * 當前顯示數據條數 - 當前行數據的索引
<el-table-column
label="序號"
type="index"
width="80px">
<template slot-scope="scope">
<span>{{total - ((currentPage-1)*pageSize) - scope.$index}}</span>
</template>
</el-table-column>