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

上一篇 下一篇

猜你喜欢

热点阅读