移动端H5中,仍旧可以使用jquery的scroll监听滚动,这个监听没有明显的延迟
yarn add jquery --save
import $ from 'jquery';
componentDidMount() {
$('.am-flexbox-item').scroll(function () {
//已经滚动到上面的页面高度
var scrollTop = $('.am-flexbox-item').scrollTop();
//页面高度
var scrollHeight = $(document).height();
//浏览器窗口高度
var windowHeight = $(window).height();
console.log('scrollTop, windowHeight, scrollHeight', scrollTop, windowHeight, scrollHeight)
//此处是滚动条到底部时候触发的事件,在这里写要加载的数据,或者是拉动滚动条的操作
if (scrollTop + windowHeight === scrollHeight) {
}
});
}