注意的是刷新在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