微信小程序之下拉刷新

分享一下我使用的上拉刷新的Demo;

其他的涉及不到  以下代码到js就可以,将代码写到js中Page里面


//下拉刷新

onPullDownRefresh: function () { //下拉刷新

wx.showToast({

title: '加载中',

icon: 'loading',

duration: 400

});

console.log('--------下拉刷新-------')

wx.showNavigationBarLoading() //在标题栏中显示加载

//这里是你请假刷新的地址 请求的地址。和你Onload 里面wx.request请求一样 粘贴过来就行

wx.request({

url: ''

method: '',

data: {},

header: {

'Accept': 'application/json'

},

success: function(res) {

}

that.setData({studate:res.data.data});

//that.data.items = res.data

},

complete: function() {

// complete

wx.hideNavigationBarLoading() //完成停止加载

wx.stopPullDownRefresh() //停止下拉刷新

}

})

},

你可能感兴趣的:(微信小程序之下拉刷新)