- 下拉刷新
页面json内加入
"enablePullDownRefresh": true,
onPullDownRefresh: function () {
setTimeout(() => {
wx.stopPullDownRefresh({
success: (res) => {
this.data.pageNo = 1;
this.getList();
},
});
}, 200);
},
async getList() {
const { result, message } = await homeList({
pageNo: this.data.pageNo,
});
if (this.data.pageNo === 1) this.data.list = [];
if (result.records && result.records.length) {
this.data.list = this.data.list.concat(result.records);
this.data.noMore = false;
} else {
if (this.data.list.length) this.data.noMore = true;
else this.data.noMore = false;
}
if (this.data.noMore) {
this.$msg("没有更多了");
}
this.setData({
list: this.data.list,
noMore: this.data.noMore,
});
},
- 上拉加载更多
- 加载列表