其他分享
首页 > 其他分享> > element table 表格组件增加前端分页

element table 表格组件增加前端分页

作者:互联网


            <el-table
                :data="giftDetailList.slice((giftDetailCurrentPage-1)*giftDetailPageSize,giftDetailCurrentPage*giftDetailPageSize)"
                height="700px" :header-cell-style="{backgroundColor:'#e6e6e6'}" border style="width: 100%">
                <el-table-column type="index" label="序号" width="50">
                </el-table-column>
                <el-table-column prop="name" label="名称">
                </el-table-column>
                <el-table-column label="操作" fixed="right" width="200">
                    <template slot-scope="scope">
                        <el-button style="color:blue;" @click="giftDetailShowVisibleTrue(scope.row)">编辑</el-button>
                        <el-button style="color:red;" @click="saveProductNewArrival(0,scope.row)">删除</el-button>
                    </template>
                </el-table-column>
            </el-table>
            <div class="block" style="margin-top:15px;">
                <el-pagination align='center' @size-change="gifthandleSizeChange"
                    @current-change="gifthandleCurrentChange" :current-page="giftDetailCurrentPage"
                    :page-sizes="[2,5,10,20]" :page-size="giftDetailPageSize"
                    layout="total, sizes, prev, pager, next, jumper" :total="giftDetailList.length">
                </el-pagination>
            </div>
     
           gifthandleSizeChange(val) {
                this.giftDetailCurrentPage = 1;
                this.giftDetailPageSize = val;
            },
            gifthandleCurrentChange(val) {
                this.giftDetailCurrentPage = val;
            },
            giftDetailList: [],
            giftDetailTitle: "",
            giftDetailCurrentPage: 1, // 当前页码
            giftDetailPageSize: 10, // 每页的数据条数
            giftDetailShowVisible: false,

关键代码:giftDetailList.slice((giftDetailCurrentPage-1)giftDetailPageSize,giftDetailCurrentPagegiftDetailPageSize)

标签:giftDetailCurrentPage,giftDetailPageSize,val,element,条数,组件,table,giftDetailList
来源: https://blog.csdn.net/hy3528/article/details/122584893