下拉刷新
<h5>小程序下拉刷新</h5>
<p><strong>问题:小程序怎么下拉刷新</strong>
<strong>解决思路:</strong>
<strong>- 首先在全局配置 window 配置enablePullDownRefresh</strong>
<strong>- 在Page页面中定义onPullDownRefresh钩子函数。到达下拉刷新条件后,该钩子函数执行,发起请求方法</strong>
<strong>- 请求返回回后,调用wx.stopPullDownRefresh停止下拉刷新</strong></p>
<p><strong>app.json</strong></p>
<pre><code class="language-javascript"> "window": {
"backgroundTextStyle": "light",
"navigationBarBackgroundColor": "#0aa6ee",
"navigationBarTitleText": "CTMS客流管理系统",
"navigationBarTextStyle": "white",
"enablePullDownRefresh": true
},</code></pre>
<p><strong>Page</strong></p>
<pre><code class="language-javascript">onPullDownRefresh() {
let that = this;
wx.showNavigationBarLoading();//导航栏lodding
wx.stopPullDownRefresh();//停止下拉刷新
setTimeout(() => {
that.statisticData(); //加载统计数据
wx.showNavigationBarLoading();
}, 3000)
},</code></pre>
<p><strong>onShow()</strong></p>
<pre><code class="language-javascript">//每次启动都会加载onShow()里面的数据
onShow: function () {
var that = this;
console.log("222");
that.statisticData(); //加载统计数据
},</code></pre>