这种上拉加载更多,是后端只返回data的情况下方可使用
//触底刷新
onReachBottom:function(){
if(this.getMeetingPersonList.length>this.pageIndex*10){
this.setLoadingStatus(true)//显示加载状态
wx.stopPullDownRefresh()//停止上拉刷新
this.loadPageData()
setTimeout(()=>{
this.setLoadingStatus(false)//显示加载状态
}.bind(this),800)
}
}
//是否显示加载状态
setLoadingStatus:function(val){
this.setData({
isLoadingFlag:val
})
}
//在调后台接口成功的前提下
success : res=> {
self.getMeetingPersonList = res.data || []
self.pageIndex = 0
self.loadPageData()
}
/**
* 上拉加载更多 meetingPerson指的是在wxml页面中需要循环的数据
* data.slice(0,this.pageIndex*10) 每次从返回的数据中取10条
*/
loadPageData:function () {
let data = this.getMeetingPersonList
this.pageIndex++
this.setData({
meetingPerson:data.slice(0,this.pageIndex*10)
})
}
复制代码