欢迎你的到此一游,在查看的过程中有疑问可在主页添加博主咨询,也可在下方评论留言。

vue+elementUI分页效果

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<div class="deit">
    <div class="crumbs">
      <el-breadcrumb separator="/">
            <el-breadcrumb-item><i class="el-icon-date"></i> 数据管理</el-breadcrumb-item>
            <el-breadcrumb-item>用户列表</el-breadcrumb-item>
        </el-breadcrumb>
        <div class="cantainer">
                    <el-table style="width: 100%;" border class="tabBg"
                    :data="allList.slice((currentPage-1)*pagesize,currentPage*pagesize)"  //当后端返回所有的数据时对数据的处理,最为重要的一句代码,如果是通过pageSize,和currentpage返回的数据就不需要这么写,直接写他的dateList就行。
                    >
                        <el-table-column type="index" width="50">   
                        </el-table-column>
                        <el-table-column label="日期" prop="date" width="180" header-align="center" align="center">   
                        </el-table-column>
                        <el-table-column label="用户姓名" prop="name" width="180">   
                        </el-table-column>
                        <el-table-column label="邮箱" prop="email" width="180">   
                        </el-table-column>
                        <el-table-column label="地址" prop="address" width="200">   
                        </el-table-column>   
                    </el-table>
                        <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="userList.length">    //这是显示总共有多少数据,
                    </el-pagination>
        </div>
    </div>
  </div>
  
  
data () {
      return {
                currentPage:1, //初始页
                pagesize:10,    //    每页的数据          
          allList: []
        }
     },
  
  
    created() {
        this.handleallList()
    },
    methods: {
        // 初始页currentPage、初始每页数据数pagesize和数据data
        handleSizeChange: function (size) {
                this.pagesize = size;
                console.log(this.pagesize)  //每页下拉显示数据
        },
        handleCurrentChange: function(currentPage){
                this.currentPage = currentPage;
                console.log(this.currentPage)  //点击第几页
        },
        handleUserList() {
            this.$http.get('http://localhost:3000/userList').then(res => {  //这是从本地请求的数据接口,
                this.allList = res.body
            })
        }
    }
 <br><br>style{<br>.tabBg .el-table_header-wrapper .has-gutter tr:nth-of-type(1) th{<br>  background-color: #eaeff5;<br>  color:#333;<br>}<br>}

  

posted @   廖客  阅读(299)  评论(0编辑  收藏  举报
编辑推荐:
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
阅读排行:
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通
点击右上角即可分享
微信分享提示