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);

浙公网安备 33010602011771号