微信小程序-下拉松开弹不回去顶部留一段空白

注意的是刷新在json 文件中要配置 "enablePullDownRefresh":true

那个空白是,加载条,可以设置一些效果,当数据完成后 用 wx.stopPullDownRefresh(); 终止效果

在 onPullDownRefresh 事件里加setTimeout事件延迟下下拉刷新的事件。

/**
  * 页面相关事件处理函数--监听用户下拉动作
  */
onPullDownRefresh: function () {
  wx.stopPullDownRefresh(); //这句也很重要
  let _This = this;
  let oUInfo = _This.data.oUInfo;
  (!oUInfo.unionId) && getApp().getUserData(function (result) {
    _This.fGetCUserInfo(result.unionId);
    _This.setData({
      oUInfo: result
    });
  });

 

  setTimeout(function () {// 这里写刷新要调用的函数,比如:
    _This.pullRefresh();
  }, 500);
 
},

注意,setTimeout要写在getApp请求之后,setTimeout只处理刷新后数据的获取。间隔时间建议为500。

转: https://www.cnblogs.com/zhangym118/p/8927022.html