美文网首页
关于iview组件中使用 table , 绑定序号分页后序号从1

关于iview组件中使用 table , 绑定序号分页后序号从1

作者: 安北分享 | 来源:发表于2021-08-16 09:50 被阅读0次

问题描述:iview使用table 中type: "index",分页之后 ,索引还是从1开始,试过绑定后台返回数据的id, 这种方法可行,就是后台返回数据的每个页面id都不完全是按照从1开始的升序,因此百度了下,找到了解决方法。

使用render:

{
    type: 'index2',
    width: 60,
    align: 'center',
    render: (h, params) => {
        return h('span', params.index + (this.page- 1) * this.pageSize + 1);
    }
}

或参考

         columns: [
                {
                    title: '序号',
                    width: 70,
                    align: 'center',
                    render: (h,params) => {
                        return h('span',params.index + (this.currentPage-1)*this.pageNum + 1 )
                    }
                }

相关文章

网友评论

      本文标题:关于iview组件中使用 table , 绑定序号分页后序号从1

      本文链接:https://www.haomeiwen.com/subject/nucmbltx.html