微信小程序上拉刷新页面数据

this.totalPages=Math.ceil(total/this.QueryParmams.pagesize);

在这里之后获取的数据不再是直接覆盖而是要使用拼接:

this.setData({
          
   
      goodslist:[...this.data.goodslist,...res.goods]
    })

最后加上事件的业务逻辑:使用if判断,存在数据时,页数+1,再一次调用获取接口数据的函数。

onReachBottom(){
          
   
  console.log("向上滑动")
  //判断是否还有下一条数据
  if(this.QueryParmams.pagenum>=this.totalPages){
          
   
    //表示没有下一页数据
    //console.log("没有下一页数据")
    wx.showToast({
          
   title:已经到底了})
  }else{
          
   
    console.log("有下一页数据")
    this.QueryParmams.pagenum++;
    this.GetGoodsList();
  }
},
经验分享 程序员 微信小程序 职场和发展