小程序下拉刷新步骤——完成

首先在app.json下“window”中进行如下设置:

"backgroundTextStyle": "dark",
"enablePullDownRefresh": true,
"onReachBottomDistance": 50
在需要进行下拉刷新的页面进行js设置:
onPullDownRefresh: function () {
  wx.showNavigationBarLoading(); //在标题栏中显示加载图标
  wx.request({
    url: 'www.XXXX.com',
    method: 'POST',
    data: {},
    success: function (res) {
      console.log(res)//完成调用后执行的函数
    },
    fail: function (res) {
      console.log(res)//调用失败后执行的函数
    },
    complete: function (res) {//调用失败或结束都会执行的函数
      wx.hideNavigationBarLoading(); //完成停止加载图标
      wx.stopPullDownRefresh();
    }
  })
}
注:header为默认设置

猜你喜欢

转载自www.cnblogs.com/lljun/p/12580925.html
今日推荐