React监听滚动
componentDidMount() { const scrollDom = document.querySelectorAll('.q1-home')[0]; scrollDom.addEventListener('scroll', this.handleScroll.bind(this)); } handleScroll(event) { const srcElement = event.srcElement; const scrollTop = srcElement.scrollTop; if (scrollTop >= 200) { // 处理 } } componentWillUnmount() { const scrollDom = document.querySelectorAll('.q1-home')[0]; scrollDom.removeEventListener('scroll', this.handleScroll.bind(this)); }