一、需要在app.json
的window选项中或页面配置中开启enablePullDownRefresh,代码如下
:
1.app.json中:
"window": {
"enablePullDownRefresh":
true
}
2.所需要刷新的页面js部分:
下拉刷新:
onPullDownRefresh:
function(){
console.log(
'
onPullDownRefresh
'
);
wx.showNavigationBarLoading()
//在标题栏中显示加载
//模拟加载
setTimeout(
function () {
wx.hideNavigationBarLoading()
//完成停止加载
wx.stopPullDownRefresh()
//停止下拉刷新
},
1000);
}
上拉触底:
onReachBottom
:
function
(){
console.log(
'
onReachBottom
'
);
wx.showNavigationBarLoading()
//在标题栏中显示加载
//模拟加载
setTimeout(
function () {
wx.hideNavigationBarLoading()
//完成停止加载
wx.stopPullDownRefresh()
//停止下拉刷新
},
1000);
}