微信小程序下拉刷新和上拉刷新

一、需要在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);
}



猜你喜欢

转载自blog.csdn.net/qq_36441761/article/details/80310010