【uniapp小程序-上拉加载】

【uniapp小程序-上拉加载】_第1张图片
在需要上拉加载的页面的page.json上添加红框框里面的

onReachBottom() {
	if(this.commentCurrent<this.commentTotal){
		this.commentCurrent += 1;	
		this.commentList();
		this.status = 'loading';
	}else{
		this.status = '';
	}
},
methods:{
	commentList(){
			let params = {
				courseid:this.courseid,
				page:this.commentCurrent
			}
			commentList(params).then((res)=>{
				let {code,list,numpage} = res
				if(code==0){
					//如果页数>1,需要拼接返回的数据
					if (this.commentCurrent > 1) {
						list = [...this.commentData, ...list];
					}
					this.commentData = list
					this.commentTotal = numpage
					uni.stopPullDownRefresh(); //拿到数据后,停止下拉刷新
					this.status = '';
				}
			})
		},
}

你可能感兴趣的:(uniapp,uni-app)