老师好,使用mescroll-uni实现上拉加载、下拉刷新为什么一直显示加载中
来源:3-6 【任务题】实现双向数据绑定功能

小小Yu
2022-01-18
<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>
写回答
1回答
-
Sunday
2022-01-18
你好
如果仅从这个代码中来看并没有发现具体的错误。你可以参考下课程的源代码,来定位问题。或者给我一个可运行的项目(在 QQ 群中可以找到我)
032022-01-18
相似问题