标签:this rem lld handles listener event selector sel pre
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)); }
标签:this rem lld handles listener event selector sel pre
原文地址:https://www.cnblogs.com/Ewarm/p/14308829.html