首页 > 其他 > 详细

elementui分页

时间:2020-05-28 18:30:20      阅读:55      评论:0      收藏:0      [点我收藏+]

1、data中声明分页所需数据:

      queryInfo: {
        total: 0,
        query: ‘‘,
        currentPage: 1, // 当前页数
        pageSize: 10 // 当前每页显示多少条数据
      }

2、引入分页组件:

    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="queryInfo.currentPage"
      :page-sizes="[10, 20, 30, 40]"
      :page-size="queryInfo.pageSize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="queryInfo.total"
    ></el-pagination>

3、请求事件中将queryInfo中的currentPage和pageSize作为请求参数,请求成功后将total赋给分页中的total:

    async getDatasummaryList() {
      let data = {
        dependentId: this.fileType,
        fileName: this.fileName,
        hospitalId: hospitalId(),
        page: this.queryInfo.currentPage,
        size: this.queryInfo.pageSize
      }
      let res = await datasummaryListApi(data)
      if (res.state === 200) {
        this.tableData = res.results.records
        this.queryInfo.total = res.results.total
      }
    }

4、分页的两个事件,将数据赋值好后重新触发请求:

    handleSizeChange(pageSize) {
      this.queryInfo.pageSize = pageSize
      this.getDatasummaryList()
    },
    handleCurrentChange(currentPage) {
      this.queryInfo.currentPage = currentPage
      this.getDatasummaryList()
    }

 

elementui分页

原文:https://www.cnblogs.com/wuqilang/p/12981960.html

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