How to make the serial number continue to increase when the element-ui form table turns the page

When using element-UI's el-table, we added type="index", and if index is set, the index of the row will be displayed (calculated from 1).
But each page is counted from 1. When we want to switch the page number, we hope that the serial number will follow the previous page, so as to realize the increment/continuation of the page turning serial number of the table.
insert image description here
The following demonstrates how to increase the sequence number when switching between pages. The code is as follows:
Structure

<el-table-column label="序号" type="index" :index="indexAdd" width="50" />

js

<script>
export default {
    
    
data() {
    
    
    return {
    
    
    // 实现分页
      pageParams: {
    
    
        page: 1, // 查询第一页
        pagesize: 2 // 每页2条
      },
 methods: {
    
      
 ......其它代码已省略,只演示序号递增实现的代码   
// type序号-页面切换递增
    indexAdd(index) {
    
    
      // console.log(index)
      const page = this.pageParams.page // 当前页码
      const pagesize = this.pageParams.pagesize // 每页条数
      return index + 1 + (page - 1) * pagesize
       }
    }
 }
</script>

after effect
insert image description here

Guess you like

Origin blog.csdn.net/weixin_48585264/article/details/119780737