react中如何使用onScroll
2019-02-20 本文已影响2人
春木橙云
复制下面的代码即可
constructor(props){
super(props)
this.state = {};
this.scrollTop = 0;
this.handleScroll = this.handleScroll.bind(this)
}
componentWillMount(){
window.addEventListener('scroll', this.handleScroll)
}
componentWillUnmount(){
window.removeEventListener('scroll',this.handleScroll)
}
THE END