这篇文章给大家分享的是有关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" >
<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;
},
}
}
实现如图效果
感谢各位的阅读!关于“vue如何实现表格分页功能”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,让大家可以学到更多知识,如果觉得文章不错,可以把它分享出去让更多的人看到吧!
亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。