vant list 分页问题

vant list 分页问题是项目中基本都会遇到的,但是还是记录一下吧,万一哪天脑袋短路不会写了怎么办(略略略~~)

	// list 是vant按需引入的组件 
	// demand-accept-list 是自定义列表组件(分页写到组件外面)
	// null-data  自定义空数据页面(有需要的自己画界面吧)
	<list   
      v-model="loading"
      :finished="finished"
      :finished-text="showEmpty ? '' : '没有更多了'"
      :immediate-check="false"
      @load="onLoad"
    >
      <demand-accept-list :list="acceptList" :tab-index="tabIndex" />
    </list>

    <null-data v-if="showEmpty" msg="暂无信息" />
   selectDemandMyList() {
      this.showEmpty = false;
      // apiVolunteerWebDemandList 这个是我的请求接口(按照自己的接口写吧)
      apiVolunteerWebDemandList(this.dataForm).then(data => {
        console.log(data, '数acceptList据');
        this.loading = false;
        let length = 0;
        if (data.content) {
          length = data.content.length;
        } else {
          this.finished = true;
          this.showEmpty = true;
        }
        if (length) {
          this.acceptList = this.acceptList.concat(data.content);
          if (length < this.dataForm.pageSize) {
            this.finished = true;
          } else {
            this.dataForm.pageNow++;
          }
        } else {
          this.finished = true;
          if (this.dataForm.pageNow === 1) {
            this.showEmpty = true;
          }
        }
      });
    },

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值