原創(chuàng)聲明:本文為作者原創(chuàng),未經(jīng)允許不得轉(zhuǎn)載,經(jīng)授權(quán)轉(zhuǎn)載需注明作者和出處
如下圖:Page頁的事件,onLoad,onShow很容易測試。
onPullDownRefresh()和onReachBottom沒看懂,也不知道如何測試!
困擾了好久~
頁面拉到頂部后,再拉就觸發(fā)此事件!(在app.json的window開啟)
即和微信朋友圈下拉相似,一拉就刷新。
頁面高度大于屏幕高,才容易看出效果。
頁面拉到底部就觸發(fā),瀑布流動態(tài)加載會用到。
//2:js代碼
Page({
onPullDownRefresh: function () {
console.log("onPullDownRefresh");
},
onReachBottom: function () {
console.log("onReachBottom");
}
})
//3:WXML代碼
<view class="container log-list">
<scroll-view class="area1">
區(qū)域A
</scroll-view>
<scroll-view class="area2">
區(qū)域B
<text id="vv">(保證大于屏幕的高度,出現(xiàn)下拉框)</text>
</scroll-view>
<scroll-view class="area3">
區(qū)域C
</scroll-view>
</view>
//4:WXSS
.log-list {
display: flex;
flex-direction: column;
padding: 40rpx;
}
.log-item {
margin: 10rpx;
}
.area1 {
height: 200rpx;
background-color: greenyellow;
text-align: center;
line-height: 200rpx;
font-weight: bold;
color: red;
}
.area2 {
height: 1300rpx;
background-color: yellow;
text-align: center;
line-height: 1300rpx;
font-weight: bold;
color: red;
}
.area3 {
height: 200rpx;
background-color: aqua;
text-align: center;
line-height: 200rpx;
font-weight: bold;
color: red;
}