首先在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為默認設置