• ElementUI实现表格分页功能


    <!DOCTYPE html>
    <html lang="en">
    
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta http-equiv="X-UA-Compatible" content="ie=edge">
        <title>表格数据分页</title>
        <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
    </head>
    
    <body>
        <div id="vue">
            <el-table :data="table_list.slice((currentPage-1)*pagesize,currentPage*pagesize)"
                :default-sort="{prop: 'date', order: 'descending'}" height="450" border style=" 100%" stripe
                highlight-current-row>
                <el-table-column label="序号">
                    <template slot-scope="scope">
                        {{scope.$index+1}}
                    </template>
                </el-table-column>
                <el-table-column prop="date" label="工号">
                </el-table-column>
                <el-table-column prop="name" label="姓名">
                </el-table-column>
                <el-table-column prop="address" label="职位">
                </el-table-column>
                <el-table-column fixed="right" label="操作" width="100">
                    <template slot-scope="scope">
                        <el-button type="text" size="small">移除
                        </el-button>
                    </template>
                </el-table-column>
            </el-table>
            <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="currentPage"
                :page-sizes="[10, 20, 50, 100]" :page-size="pagesize" layout="total, sizes, prev, pager, next, jumper"
                :total="table_list.length">
            </el-pagination>
    
        </div>
    </body>
    <script src="http://cdn.suoluomei.com/common/js2.0/vue/v2.5.16/vue.js"></script>
    <script src="https://cdn.suoluomei.com/common/js2.0/element-ui/2.12/lib/theme-chalk/index.js"></script>
    
    
    <script>
    
        new Vue({
            el: '#vue',
            data: {
                table_list: [{
                    date: '20160503',
                    name: '王小虎',
                    address: '销售'
                }, {
                    date: '20160502',
                    name: '王小虎',
                    address: '销售'
                }, {
                    date: '20160504',
                    name: '王小虎',
                    address: '销售'
                }, {
                    date: '20160501',
                    name: '王小虎',
                    address: '销售'
                }, {
                    date: '20160508',
                    name: '王小虎',
                    address: '销售'
                }, {
                    date: '20160506',
                    name: '王小虎',
                    address: '销售'
                }, {
                    date: '20160507',
                    name: '王小虎',
                    address: '销售'
                }],
                currentPage: 1,
                pagesize: 10,
    
            },
            methods: {
                handleSizeChange: function (size) {
                    this.pagesize = size;
                },
                handleCurrentChange: function (currentPage) {
                    this.currentPage = currentPage;
                }
            }
        })
    </script>
    
    </html>

     

     转自:https://cloud.tencent.com/developer/article/1691239
  • 相关阅读:
    洛谷 P1875 佳佳的魔法药水
    洛谷 P4822 [BJWC2012]冻结
    洛谷 P6175 无向图的最小环问题
    洛谷 P1312 Mayan游戏
    洛谷 P1311 选择客栈
    洛谷 T150024 矩形面积并(扫描线)
    洛谷 P1311 选择客栈
    洛谷 P1514 引水入城
    洛谷 P1310 表达式的值
    求和(团队题目)
  • 原文地址:https://www.cnblogs.com/javalinux/p/14805940.html
Copyright © 2020-2023  润新知