问题描述
我目前正在构建一个带有滚动处理程序的React应用,以在无限滚动组件中加载更多数据.我正在使用window.addEventListener('scroll', this.someScrollHandler, false);
(带节流),该功能可在除IE之外的所有浏览器上使用-不处理任何事件.
实际上,在IE控制台中进行测试,下面的代码然后滚动,不会产生日志记录:
window.addEventListener('scroll', function() { console.log('testing') }, false);
滚动事件和IE发生了什么事?
我的问题是我的身高为100%,从而禁用了滚动事件.
body {
height: 100%; // <-- will disable window.addEventListener('scroll')
}
I'm currently building a React app with a scroll handler for loading more data in an infinite scroll component. I'm using window.addEventListener('scroll', this.someScrollHandler, false);
(with throttling), which works on every browser except for IE — no event is handled.
In fact, testing in the IE console, the below code, then scrolling, results in no logging:
window.addEventListener('scroll', function() { console.log('testing') }, false);
What's going on with scroll events and IE?
My problem was that I had the body height 100%, that disabled the scroll event.
body {
height: 100%; // <-- will disable window.addEventListener('scroll')
}
这篇关于为什么window.addEventListener('scroll',this.someScrollHandler,false)在IE 10上不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!