请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

老师好,使用mescroll-uni实现上拉加载、下拉刷新为什么一直显示加载中

<template>
  <view class="dividend-list-container">
    <empty-data v-if="isEmpty"></empty-data>
    <mescroll-body
      v-else
      ref="mescrollRef"
      @init="mescrollInit"
      @up="upCallBack"
      @down="downCallBack"
      :up="{
        textNoMore: '--我也是有底线的!--',
      }"
    >
      <block v-for="(item, index) in resultList" :key="index">
        <history-netvalue-item
          :item="item"
          surceType="dividendMethodList"
        ></history-netvalue-item>
      </block>
    </mescroll-body>
  </view>
</template>

<script>
import { dividendList } from "api/my";
import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
export default {
  mixins: [MescrollMixin],
  data() {
    return {
      page: 1,
      size: 10,
      resultList: [],
      isInit: true,
      mescroll: null,
      isEmpty: false,
    };
  },
  mounted() {
    this.mescroll = this.$refs.mescrollRef.mescroll;
    console.log("this.mescroll", this.mescroll);
  },
  onShow() {
    // this.loadReaultList();
  },
  methods: {
    async loadReaultList() {
      let res = await dividendList({
        pageNo: this.page,
        pageSize: this.size,
      });
      if (this.page == 1) {
        this.resultList = res.data.dividendRespData;
      } else {
        this.resultList = [...this.resultList, ...res.data.dividendRespData];
      }
      this.resultList.forEach((item) => {
        item.num = (item.totalFundVol * item.netValue).toFixed(2);
      });
      if (this.resultList.length === 0) {
        this.isEmpty = true;
      }
    },
    async mescrollInit() {
      console.log("首次加载");
      await this.loadReaultList();
      this.isInit = false;
      this.mescroll.endSuccess();
    },
    async downCallBack() {
      console.log("下拉刷新回调");
      if (this.isInit) return;
      this.page = 1;
      await this.loadReaultList();
      this.mescroll.endSuccess();
    },
    async upCallBack() {
      console.log("上拉加载回调");
      if (this.isInit) return;
      this.page += 1;
      await this.loadReaultList();
      this.mescroll.endSuccess();
    },
  },
};
</script>

<style lang="scss" scoped>
.dividend-list-container {
  width: 100%;
  height: 100%;
  .item-title {
    width: 100%;
    height: 50px;
    line-height: 50px;
    background: $uni-title-bg-color;
    display: flex;
    align-content: center;
    justify-content: space-between;
    font-family: PingFangSC-Regular;
    font-size: $uni-font-size-base;
    padding-left: 4%;
    color: $uni-text-title-color;
    // margin-top: 0.1%;
    .right-btn {
      padding-right: 8%;
    }
  }
}
</style>


正在回答 回答被采纳积分+3

1回答

程序员Sunday 2022-01-18 16:05:51

你好

如果仅从这个代码中来看并没有发现具体的错误。你可以参考下课程的源代码,来定位问题。或者给我一个可运行的项目(在 QQ 群中可以找到我)

0 回复 有任何疑惑可以回复我~
  • 提问者 小小Yu #1
    老师,qq群是多少呢~
    回复 有任何疑惑可以回复我~ 2022-01-18 16:12:51
  • 提问者 小小Yu #2
    老师,找到了,不好意思~
    回复 有任何疑惑可以回复我~ 2022-01-18 16:28:28
  • 程序员Sunday 回复 提问者 小小Yu #3
    嗯嗯, 申请入群的时候需要输入《课程订单号》作为入群验证
    回复 有任何疑惑可以回复我~ 2022-01-18 16:34:23
问题已解决,确定采纳
还有疑问,暂不采纳
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号