数据没有全部加载完毕就展示了底线视图
来源:8-16 评论列表 - 处理数据加载完成的提示

雪豹闭嘴
2022-11-11
<mescroll-body ref="mescrollRef" @init="mescrollInit" :down="{
use: false
}" @up="upCallback" :up="{
textNoMore: '-- 我也是有底线的!! --'
}">
async mescrollInit() {
await this.loadArticleCommentList()
this.isInit = false;
this.getMescroll().endSuccess();
console.log(`当获取到的评论数量:${this.commentList.length}, 全部的评论数量:${this.commentListTotal}`)
this.getMescroll().endBySize(this.commentList.length, this.commentListTotal);
},
async upCallback() {
if (this.isInit) return;
this.page += 1;
await this.loadArticleCommentList();
this.getMescroll().endSuccess();
console.log(`当获取到的评论数量:${this.commentList.length}, 全部的评论数量:${this.commentListTotal}`)
this.getMescroll().endBySize(this.commentList.length, this.commentListTotal);
},
getMescroll() {
if (this.$refs.mescrollRef) {
this.mescroll = this.$refs.mescrollRef.mescroll
}
return this.mescroll;
},
async loadArticleCommentList() {
const {
data: res
} = await getArticleCommentList({
articleId: this.articleId,
page: this.page,
size: this.size
})
this.commentListTotal = res.count;
if (this.page === 1) {
this.commentList = res.list
} else {
this.commentList = [...this.commentList, ...res.list]
}
},
写回答
2回答
-
022022-11-11
-
雪豹闭嘴
提问者
2022-11-11
解决了
this.getMescroll().endSuccess(this.commentList.length, this.commentList.length < this.commentListTotal);
012023-11-20
相似问题