基于vue框架制作表格分页功能的方法及代码是什么
Admin 2022-06-27 群英技术资讯 773 次浏览
今天小编跟大家讲解下有关“基于vue框架制作表格分页功能的方法及代码是什么”的内容 ,相信小伙伴们对这个话题应该有所关注吧,小编也收集到了相关资料,希望小伙伴们看了有所帮助。本文实例为大家分享了vue实现表格分页功能的具体代码,供大家参考,具体内容如下
直接上代码:
这里是这里是template部分,主要由一个需要分页的表格和一个分页器组成。重点在于表格的data属性用到了一个slice截取方法。
<el-table
v-loading="listLoading"
:data="
list.slice((currentPage - 1) * pageSize, currentPage * pageSize)
"
element-loading-text="Loading"
highlight-current-row
border
>
<el-table-column align="center" label="序号" width="90">
<template slot-scope="scope">
{{ scope.$index + 1 }}
</template>
</el-table-column>
<el-table-column label="头像" align="center" width="150">
<template slot-scope="scope">
<el-avatar :src="scope.row.avatar"></el-avatar>
</template>
</el-table-column>
<el-table-column align="center" label="UID" width="130">
<template slot-scope="scope">
{{ scope.row.UID }}
</template>
</el-table-column>
<el-table-column align="center" label="用户名" width="350">
<template slot-scope="scope">
{{ scope.row.username }}
</template>
</el-table-column>
<el-table-column align="center" label="游戏ID" width="350">
<template slot-scope="scope"> {{ scope.row.usernick }} </template>
</el-table-column>
<el-table-column label="授权类型" width="110" align="center">
<template slot-scope="scope">
<el-tag :type="scope.row.authorizationType | tagTypeFilter">{{
scope.row.authorizationType | authorizationTypeFilter
}}</el-tag>
</template>
</el-table-column>
<el-table-column align="center" label="成功邀请人数" width="150">
<template slot-scope="scope">{{ scope.row.successNum }} </template>
</el-table-column>
<!-- <el-table-column align="center" label="操作" width="150">
<template slot-scope="scope">
<el-button
type="primary"
size="mini"
@click="change(scope.$index, scope.row)"
>
修改
</el-button>
</template>
</el-table-column> -->
</el-table>
<!-- 分页器 -->
<div class="block" style="margin-top: 15px">
<el-pagination
align="right"
@current-change="handleCurrentChange"
:current-page="currentPage"
:page-size="pageSize"
layout="prev, pager, next,total"
background
:total="filterList.length"
hide-on-single-page
>
</el-pagination>
</div>
这里是javascript部分:
export default{
data(){
return{
currentPage:1//当前页码
pageSize:10//每页显示条数
list:[]//要显示的表格数据
}
}
methods{
handleCurrentChange(val) {
this.currentPage = val;
},
}
}
实现如图效果

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:mmqy2019@163.com进行举报,并提供相关证据,查实之后,将立刻删除涉嫌侵权内容。
猜你喜欢
pinia是一个轻量级的状态管理库,属于 vue3 生态圈新的成员之一,下面这篇文章主要给大家介绍了关于Vue项目新一代状态管理工具Pinia的使用教程,需要的朋友可以参考下
目录使用create,mounted调用方法我之前有个错误的写法错误有2mounted方法和created区别使用create,mounted调用方法首先:我之前有个错误的写法错误有21,我一直以为在created里定义方法然后使用,其实这里的getCustomerInfo只是调用2,所有的方法都应该在methods里
目录前言:函数提升var变量提升let const提升Class提升前言:JavaScript中奇怪的一点是你可以在变量和函数声明之前使用它们。就好像是变量声明和函数声明被提升了代码的顶部一样。sayHi() // Hi there!function sayHi() { console.log(Hi there
这篇文章主要为大家详细介绍了js实现模态窗口增加与删除,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
在JavaScript中,函数是第一类对象,这意味着函数可以像对象一样按照第一类管理被使用。既然函数实际上是对象:它们能被“存储”在变量中,能作为函数参数被传递,能在函数中被创建,能从函数中返回。
成为群英会员,开启智能安全云计算之旅
立即注册Copyright © QY Network Company Ltd. All Rights Reserved. 2003-2020 群英 版权所有
增值电信经营许可证 : B1.B2-20140078 粤ICP备09006778号 域名注册商资质 粤 D3.1-20240008