时间:2021-07-01 10:21:17 帮助过:1220人阅读
export class Example extends Component{
scrollHandler = this.handleScroll.bind(this);
componentDidMount() {
window.addEventListener('scroll', this.scrollHandler);
}
_handleScroll(scrollTop) {
console.log(scrollTop) //滚动条距离页面的高度
}
}
handleScroll(event) {
let scrollTop = event.srcElement.body.scrollTop;
this._handleScroll(scrollTop);
}
}
以上就是如何实现ReactJS 监听页面滚动事件 的详细内容,更多请关注Gxl网其它相关文章!