2022-06-08 react window.addEventListener 无效
作者:互联网
代码:
componentDidMount() { window.addEventListener('scroll', this.handleScroll); }handleScroll = (e) => { console.log(e); }
解决方案:
window.addEventListener('scroll', this.handleScroll)添加一个true,即:
window.addEventListener('scroll', this.handleScroll, true);
标签:06,08,react,handleScroll,window,addEventListener,true,scroll 来源: https://www.cnblogs.com/iuniko/p/16355424.html