页面事件处理函数-onPullDownRefresh()
(1) 需要在app.json的window选项中或页面配置中开启enablePullDownRefresh。
(2) 可以通过wx.startPullDownRefresh触发下拉刷新,调用后触发下拉刷新动画,效果与用户手动下拉刷新一致。
(3) 当处理完数据刷新后,wx.stopPullDownRefresh可以停止当前页面的下拉刷新。
1、在app.json的 window 选项中或页面配置种设置 enablePullDownRefresh
{
"enablePullDownRefresh": true,
"onReachBottomDistance": 50
}
2、配置 backgroundTextStyle
window下修改 backgroundTextStyle:下拉 loading 的样式,默认是light,仅支持 dark / light
{
"backgroundTextStyle": "dark"
}
3、wx.stopPullDownRefresh
当处理完数据刷新后,可以用 stopPullDownRefresh 停止当前页面的下拉刷新。
Page({
onPullDownRefresh: function(){
wx.showNavigationBarLoading(); //在标题栏中显示加载图标
wx.request({
url: 'www.XXXX.com/xxx/xxxx',
method: 'POST',
header: {
'content-type': 'application/json'
},
data: {},
success: function (res) {
},
fail: function (res) {
},
complete: function (res) {
wx.hideNavigationBarLoading(); //完成停止加载图标
wx.stopPullDownRefresh();
}
})
}
})