element表格設置序號

1.在template中

<el-table-column prop="index" label="序號" width="55" align="left"></el-table-column>

2.在方法中

 // 添加序號
this.tableData.map((item, index) => {
     item.index = this.tableListQuery.limit * (this.tableListQuery.page - 1) + (index + 1);
     if (index === 0) {
         this.curStartTerIndex = this.tableListQuery.limit * (this.tableListQuery.page - 1) + (index + 1);
      }
     if (index === this.tableData.length - 1) {
         this.curEndTerIndex = this.tableListQuery.limit * (this.tableListQuery.page - 1) + (index + 1);
     }
     return item;
});

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章