vue前端分页

Vue前端分页实现
<div class="pagination-wrapper">
      <span class="total-items">共 {{ projectList.length }} 条</span>

      <el-select
        v-model="pageSize" size="mini" style="width: 100px; margin: 0 10px;" @change="handleSizeChange"
      ><el-option
        v-for="item in pageSizeOptions" :key="item" :label="`${item}条/页`" :value="item"></el-option>
      </el-select>

      <el-pagination
        backgroundsa
        :current-page="currentPage"
        :page-size="pageSize"
        :total="projectList.length"
        layout="prev, pager, next, jumper"
        @current-change="handleCurrentChange"
      />
    </div>

 data(){

定义

      currentPage: 1,  // 当前页码
      showFilesPage: [],
      pageSizeOptions: [5, 10, 20, 50, 100],
      pageSize: 20,

}

methods区域

在获取table的数组所有值值,需要在

getList: debounceWrapper(function () {
      this.loading = true;
      this.btnLoading = true;
      getDetailList(this.queryParams, this.backUrl).then(
        response => {
          console.log('response======',response.data.length);
          this.total = response.data.length;
          this.projectList = response.data;
          this.calcPageData()
          this.loading = false
        }
      );
    }),
    // 前端处理分页
    calcPageData() {
      const begin = (this.currentPage - 1) * this.pageSize
      const end = this.currentPage * this.pageSize
      this.showFilesPage = this.projectList.slice(begin, end)
    },
    handleCurrentChange(val) {
      this.currentPage = val;
      this.calcPageData()
    },
    handleSizeChange(val) {
      this.pageSize = val
      this.currentPage = 1
      this.calcPageData()
    },

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值