oppo下拉刷新无限请求
发布于 5 年前 作者 mingfu 5377 次浏览 来自 问答
  • 当前 Bug 的表现(可附上截图)
  • 预期表现
  • 复现路径
  • 提供一个最简复现 Demo

数据请求刚开始一切正常,一旦下拉刷新,就会无限调用请求函数。没有办法停止。微信版本最新,基础库版本也高。目前只发现oppo手机出现该类问题

下拉刷新的代码如下所示:
onPullDownRefresh: function() {
this.clearCache();//清空列表和页码
this.net(0);//获取第一页的数据
setTimeout(function() {
wx.stopPullDownRefresh();//一秒后停止刷新
}, 1000)
},

net: function(pg) {
wx.showLoading({
title: ‘加载中’,
})
let that = this;
pg = pg ? pg : 0;
pg += 1;
wx.showNavigationBarLoading()
wx.request({
url: “XXXXx”,
method:“POST”,
header: {
‘content-type’: ‘application/json’,
Authorization: wx.getStorageSync(“access_token”)
},
data: {
pageNum: pg,
pageSize: 5
},
success: function(res) {
console.log(“列表”, res)

if (res.code == 1) {

      if (res.data) {
        var tmpArr = that.data.list;
        tmpArr.push.apply(tmpArr, res.data.list);
        that.setData({
          list: tmpArr,
          total: res.data.total
        })
      } else {
        wx.showToast({
          title: '没有更多数据',
          icon: "none"
        })

      }
    }
    setTimeout(function () {
      wx.hideLoading()
      wx.hideNavigationBarLoading();
      wx.stopPullDownRefresh();//停止刷新
    }, 1000)
  }
})

},

2 回复

自己加锁

回到顶部