为什么window.addEventListener('scroll',this.someScrollHandler,false)在IE 10上不起作用? [英] Why doesn't window.addEventListener('scroll', this.someScrollHandler, false) work on IE 10?

查看:530
本文介绍了为什么window.addEventListener('scroll',this.someScrollHandler,false)在IE 10上不起作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在构建一个带有滚动处理程序的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上不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆