个人理解:在触发下拉时,调用onload,实现重新加载的目的。所以想要触发刷新时,也可以在添加信息后,触发下拉
wx.startPullDownRefresh();实现刷新的目的。
当然是先目的后关闭下拉:
wx.stopPullDownRefresh()在这些之前,要在app.json中开启下拉:
"window":{ "backgroundTextStyle":"dark", "navigationBarBackgroundColor": "fff", "navigationBarTitleText": "啊啊啊", "navigationBarTextStyle":"black", "enablePullDownRefresh": true },backgroundTextStyle 设置为 dark 是为了可见下拉时的三个点。。
示例:
/** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { var that = this; // console.log(options.uid); //2 wx.request({ url: getApp().globalData.server + 'index/index/address', data: { // id: options.uid, }, header: { 'content-type': 'application/json' // 默认值 }, method: 'GET', success: function (res) { console.log(res.data); //3 if (res.data.msg == '0') { console.log(res.data.msg); } else { console.log(res.data.address); var address = res.data.address; that.setData({ items: address, }) wx.stopPullDownRefresh() } } }) },小程序













