首页 > 其他 > 详细

vue 假分页实现

时间:2021-02-25 15:07:45      阅读:82      评论:0      收藏:0      [点我收藏+]
1.模板中
<el-table :data="rolelist.slice((currentPage-1)*pagesize,currentPage*pagesize)" border >
                <el-table-column type="index"></el-table-column>
                <el-table-column label="角色名称" prop="roleName"></el-table-column>
                <el-table-column label="角色描述" prop="roleDesc"></el-table-column>
                <el-table-column label="操作" width="300px">
                    <template slot-scope="scope">
                        <el-button size="mini" type="primary" icon="el-icon-edit" @click="showEditDialog(scope.row.id)" >编辑</el-button>
                        <el-button size="mini" type="danger" icon="el-icon-delete" @click="deleteRoleById(scope.row.id)">删除</el-button>
                        <el-button size="mini" type="warning" icon="el-icon-setting" @click="showSetRightDialog(scope.row)">分配权限</el-button>
                    </template>
                </el-table-column>
            </el-table>
    
  <!-- 分页导航区域 
        @size-change(pagesize改变时触发) 
        @current-change(页码发生改变时触发)
        :current-page(设置当前页码)
        :page-size(设置每页的数据条数)
        :total(设置总页数) -->
   <el-pagination
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :current-page="currentPage"
            :page-sizes="[5, 10, 20, 40]" 
            :page-size="pagesize"         
            layout="total, sizes, prev, pager, next, jumper"
            :total="rolelist.length">   
            </el-pagination>
2.脚本
<script>
export default {
    data(){
        return{
            rolelist:[],//列表
            currentPage:1, //初始页
            pagesize:10,    //    每页的数据
        }
    },
 
    methods:{
         // 初始页currentPage、初始每页数据数pagesize和数据data
        handleSizeChange: function (size) {
              this.pagesize = size;
              console.log(this.pagesize)  //每页下拉显示数据
        },
        handleCurrentChange: function(currentPage){
              this.currentPage = currentPage;
              console.log(this.currentPage)  //点击第几页
        },
 }
}
3.开心的玩耍

vue 假分页实现

原文:https://www.cnblogs.com/wakaka623/p/14446597.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!