element-ui的el-table中添加遞增序號


 

 效果如上所示,

不論在表格中如何新增刪除表格數據,序號總是從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分頁即可。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM