vant移动端上滑下拉加载

 <ul class="content">
      <li>
        <van-pull-refresh v-model="isDownLoading" @refresh="onDownRefresh">
          <van-list
            v-model="isUpLoading"
            :finished="finished"
            :immediate-check="false"
            :offset="offset"
            :finished-text="txts"
            @load="onLoadList"
          >
            <div v-if="tableList.length > 0" class="allcontent">
              <div
                v-for="(item, index) in tableList"
                :key="index"
                class="item"
                @click="goApply(item)"
              >
                <van-row>
                  <van-col span="12"> 名称:{{ item.name }} </van-col>
                  <van-col span="12"> 规格:{{ item.specifications }} </van-col>
                </van-row>
                <van-row>
                  <van-col span="12"> 纯度: {{ item.purity }}</van-col>
                  <van-col span="12"> 浓度: {{ item.concentration }}</van-col>
                </van-row>
              </div>
            </div>
          </van-list>
        </van-pull-refresh>
      </li>
    </ul>
  data() {
  return {
        queryParams: {
        pageNum: 1,
        pageSize: 10,
        deposit: null,
        number: null,
        category: null,
      },
      tableList: [], //展示数据
      isDownLoading: false, // 下拉刷新
      isUpLoading: false, // 上拉加载
      finished: false, // 上拉加载完毕
      offset: 10, // 滚动条与底部距离小于 offset 时触发load事件
      txts: "没有更多了",
     }
  }

//获取数据
 listTaccount() {
      this.$request(this.$Api.listTaccount, this.queryParams, "get")
        .then((res) => {
          this.total = res.total;
          var rows = res.rows;
          if (rows == null || rows.length === 0) {
            this.tableList = rows;
            this.txts = "暂无数据";
            // 加载结束
            this.finished = true;
            return;
          }
          if (rows.length < this.queryParams.pageSize) {
            // 最后一页不足或等于10条的情况
            this.finished = true;
          }

          // 处理数据
          if (this.queryParams.pageNum == 1) {
            this.tableList = rows;
          } else {
            this.tableList = this.tableList.concat(rows);
            console.log("hhhhhh");
          }

          if (this.tableList.length >= res.total) {
            this.finished = true;
          } else {
            this.finished = false;
          }
        })
        .catch((e) => {
          console.log(e);
        })
        .finally(() => {
          this.isDownLoading = false;
          this.isUpLoading = false;
        });
    },

    onDownRefresh() {
      console.log("下拉");
      this.tableList = [];
      this.queryParams.pageNum = 1;
      this.finished = true; // 不写这句会导致你上拉到底过后在下拉刷新将不能触发下拉加载事件
      this.listTaccount(); // 加载数据
    },
    // 上拉加载请求方法
    onLoadList() {
      console.log("上拉");
      this.queryParams.pageNum++;
      this.listTaccount();
    },```

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值