preface
Today in the small program with onPageScroll to write the rolling monitor, was suddenly feedback failure, suddenly feel a tight heart, good function how to say that it doesn’t work doesn’t work?
why
<page>
<view class="body">
<view class="view">{{desc}}</view>
</view>
</page>
Copy the code
The page element and the view element with class.body must not be set to heigit: 100%; Otherwise, onPageScroll will not fire no matter how much the height of the element class.view exceeds the height of the window.
page { overflow: hidden; } .body { height: 100%; / / or 100 vh; }Copy the code
Add overflow: hidden on page to prevent scrolling through; Height: 100%; , causing onPageScroll not to fire.
To solve
The page element and the view element with class.body have at least one setting height:auto; Otherwise, onPageScroll will not fire. The problem is solved, but does anybody know how it works?
Reference Documents:
The sign-up page