关于iview组件中使用 table , 绑定序号分页后序号从1开始的解决方案

问题描述: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 )
                    }
                }


喜欢的朋友记得点赞、收藏、关注哦!!!

你可能感兴趣的:(面试题汇总与解析,课程设计,spring,boot,vue.js,layui,毕业设计)