微信開發文檔:https://developers.weixin.qq.com/miniprogram/dev/component/scroll-view.html
一、如果使用原生的onReachBottom(上拉加載)和onPullDownRefresh(下拉刷新),需要注意
1.在xxx.json頁面不添加"onReachBottomDistance":xxx,默認下拉50(單位px)觸發onReachBottom事件。
注意:如果頁面未出滾動條,設置高度需要大於100%
2..在xxx.json頁面不添加"enablePullDownRefresh":true,不會觸發onPullDownRefresh下拉事件。
注意,如果是使用MAC OS 操作系統進行開發,要觸發onPullDownRefresh事件,需要點住進行下拉,而不是滑動下拉。
二、如果使用scroll-view
格式如下:
<scroll-view scroll-y="true" lower-threshold="100"
bindscrolltolower="lower" bindscrolltoupper="upper" upper-threshold="10">
<view></view>
</scroll-view>
重點(橫向加載/刷新同理):
1.保證page的height:100%;
2.保證scroll-view的height:100%;
3.保證scroll-view下面的樣式的height總和>100%;(這個demo可以讓view的height:101%;試一下)
如有問題,歡迎大家留言指正,謝謝!!~~