微信小程序下拉刷新
一、如何設置微信小程序所有頁面都可以下拉刷新呢?
1、在app.json的"window"中進行配置
(1)把"backgroundTextStyle":“light"改為"backgroundTextStyle”:“dark”
(2)添加"enablePullDownRefresh":true,開啟下拉刷新。
2、在app.js中增加兩個生命周期函數
onPullDownRefresh:function(){this.onRefresh();}, onRefresh:function(){//導航條加載動畫wx.showNavigationBarLoading();setTimeout(function () {wx.hideNavigationBarLoading();//停止下拉刷新wx.stopPullDownRefresh();}, 2000);},二、如何設置微信小程序單獨頁面下拉刷新呢?
1、首先在頁面的json文件中添加設置:
“enablePullDownRefresh”: true
也就是寫成下面這樣子:
2、在js文件中寫一個onRefresh()生命周期:
onRefresh:function(){//導航條加載動畫wx.showNavigationBarLoading()//loading 提示框wx.showLoading({title: 'Loading...',})console.log("下拉刷新啦");setTimeout(function () {wx.hideLoading();wx.hideNavigationBarLoading();//停止下拉刷新wx.stopPullDownRefresh();}, 2000)},2、在onPullDownRefresh()中調用上面寫的函數:
/*** 頁面相關事件處理函數--監聽用戶下拉動作*/onPullDownRefresh:function(){this.onRefresh();},效果:
這樣就可以啦,自己設置刷新時間哦。有疑問請在下方留言。
總結
- 上一篇: 【机器学习】——纯Python建立BP模
- 下一篇: 题目一:给出一个n,代表有从1到n的数字