react中如何使用onScroll

复制下面的代码即可

    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

你可能感兴趣的:(react中如何使用onScroll)