今日準備把微信小程序的下拉刷新做一下,沒想到我綁定了bindscrolltolower事件,但是居然不觸發,我設置了lower-threshold高度無濟于事.最后經過不懈的努力,找了很多資料,才發現,居然要設置scroll-view高度,于是我在.wxss里設置了高度為100%:
.scrollStyle{ width: 100%; height: 100%; display: flex; flex-direction: column; }
居然無效,修改height為具體高度也無效.
然后我在 style里設置height為200px,居然生效了:
<scroll-view style='height:{{scrollHeight}}px' class='scrollStyle' scroll-y='true' slot="0" hidden="{{curindex != 0}}" bindscrolltolower="loadMoreData" lower-threshold="100">
注意:style里的height單位必須寫px;
scrollHeight怎么來的?是獲取了屏幕高度,代碼如下:
let scrollHeight = wx.getSystemInfoSync().windowHeight; this.setData({ scrollHeight: scrollHeight });
scrollHeight其實是減去導航欄和tabbar的高度!
ps:很啃爹只能寫在style里才生效.