美文网首页
react中如何使用onScroll

react中如何使用onScroll

作者: 春木橙云 | 来源:发表于2019-02-20 16:21 被阅读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

相关文章

网友评论

      本文标题:react中如何使用onScroll

      本文链接:https://www.haomeiwen.com/subject/gcbhyqtx.html