el-table翻页序号不从1开始(已解决)

本文介绍两种在 Element UI 的 el-table 中实现自定义序号的方法,第一种通过绑定方法实现页码计算,第二种尝试使用模板作用域但出现错误。详细介绍了第一种方法的具体实现步骤。

法一:赋值方式(亲测有效)

<el-table-column
type="index"
fixed="left"
align="center"
:index="table_index" //这里绑定一个方法,将返回值赋给index,即表格每行数据的下标
>
</el-table-column>

 

然后再在methods内写页码的返回值 :

methods: {
table_index(index){

return (this.currentPage-1) * this.pageSize + index + 1
}

法二:其他博主分享的方式:

<el-table-column
label="序号"
type="index"
width="50"
align="center">
<template scope="scope">
<span>{{(page - 1) * pageSize + scope.$index + 1}}</span>
</template>
</el-table-column>

亲测该方式不行,控制台直接报错!各位可根据自身情况选择方式。

 
 
 
 
 

转载于:https://www.cnblogs.com/LindaBlog/p/11127862.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值