效果如上所示,
不論在表格中如何新增刪除表格數據,序號總是從1開始遞增排序,原理是根據表格分頁中當前頁數與當前頁條數來計算的。
<el-table-column label="序號" prop="" width="180" align="center"> <template slot-scope="scope"> <span v-text="getIndex(scope.$index)"> </span> </template> </el-table-column> //獲取表格序號 getIndex($index) { //表格序號 return (this.page.currentPage - 1) * this.page.pageSize + $index + 1 },
需要添加一個page分頁即可。