本文編輯: 大妖怪瀏覽 5010
版權(quán)所有,嚴(yán)禁轉(zhuǎn)載
接口 | 說明 |
---|---|
onPullDownRefresh | 在 Page 中定義 onPullDownRefresh 處理函數(shù),監(jiān)聽該頁面用戶下拉刷新事件 |
wx.stopPullDownRefresh | 停止當(dāng)前頁面下拉刷新 |
wxml
<view class="container">
<view>
<view class="page-section">
<view class="page-body-info">
<text class="page-body-text">下滑頁面即可刷新</text>
</view>
<view class="btn-area">
<button bindtap="stopPullDownRefresh">停止刷新</button>
</view>
</view>
</view>
</view>
js
Page({
onPullDownRefresh: function () {
wx.showToast({
title: 'loading...',
icon: 'loading'
})
//你的業(yè)務(wù)邏輯
},
stopPullDownRefresh: function () {
wx.stopPullDownRefresh({
complete: function (res) {
wx.hideToast()
console.log(res, new Date())
}
})
}
})
wxss
.page-body-info {
background-color: transparent;
}
.btn-area{
margin-top: 300rpx;
}
.container {
display: flex;
flex-direction: column;
min-height: 100%;
justify-content: space-between;
font-size: 32rpx;
font-family: -apple-system-font,Helvetica Neue,Helvetica,sans-serif;
}
.page-body-text {
font-size: 30rpx;
line-height: 26px;
color: #ccc;
}
【onPullDownRefresh】:【在 Page 中定義 onPullDownRefresh 處理函數(shù),監(jiān)聽該頁面用戶下拉刷新事件】
【wx.stopPullDownRefresh】:【停止當(dāng)前頁面下拉刷新】
Page({
onPullDownRefresh: function(){
wx.stopPullDownRefresh()
}
})
bug&tip:
1.需要在 config 的window選項(xiàng)中開啟 enablePullDownRefresh(即在app.json文件的window下設(shè)置enablePullDownRefresh屬性為true,默認(rèn)為false)
2.當(dāng)處理完數(shù)據(jù)刷新后,wx.stopPullDownRefresh可以停止當(dāng)前頁面的下拉刷新