react.js 监听滚动事件:window.addEventListener的scroll问题
·
// 组件加载时
componentDidMount () {
window.addEventListener('scroll', this.handleScroll, true)
}
// 组件卸载时
componentWillUnmount () {
window.removeEventListener('scroll', this.handleScroll, true)
}
// 监听滚动
handleScroll = () => {
console.log('进来',document.documentElement.scrollTop)
}

更多推荐
所有评论(0)