First of all, the table has a built-in type= ‘index’ attribute. This attribute can be the current column is replaced by the index 1,2,3,4,5, but it will reset every page. Is there a way that it can inherit the index of the previous page
<el-table-column
type="index"
:index="indexMethod">
</el-table-column>
Copy the code
You can customize an index by passing the index attribute to columns of type=index. This property, when passed a number, is used as the starting value for the index. You can also pass in a method that takes the row number of the current row (starting from 0) as an argument, and the return value is displayed as an index.
We know that when indexMethod is given a value, the current page will be incremented according to the starting value of the indexMethod. Assuming the value is 25, the current page will be numbered 25,26,27,28,29,30Copy the code
Then the question arises, how do we know what initial value to give the current page
One of my own solutions is to calculate based on the current page
When we select the second page, the value of indexMethod should be the number of previous pages multiplied by the number of codes per page as follows: the calculated attribute is most appropriate
computed: {
indexMethod: function() {
return (this.pagination.page - 1) * (this.pagination.pagesize) + 1
}
}
Copy the code
The previous page is the current page number -1, and the initial value of the indexMethod will be the first value of the current page, so the final value will be +1