对象不支持属性或方法'addEventListener'
'jQuery' is undefined
我正在使用IE 11,
/jquery-2.1.1.min.js
jquery-migrate-1.1.1.js
和jquery-ui-1.11.0.custom/jquery-ui.js(主题定制器)。
在2.1.1之前,我在Chrome中使用1.11.1(正常工作)。
我尝试过这个修复方法,但对我没有起作用。
对象不支持属性或方法'addEventListener'
'jQuery' is undefined
我正在使用IE 11,
/jquery-2.1.1.min.js
jquery-migrate-1.1.1.js
和jquery-ui-1.11.0.custom/jquery-ui.js(主题定制器)。
在2.1.1之前,我在Chrome中使用1.11.1(正常工作)。
我尝试过这个修复方法,但对我没有起作用。
正如 Arnaud 在原帖的评论中建议的那样,您应该将此放在html头部:
As Arnaud suggested in a comment to the original post, you should put this in your html header:<meta http-equiv="X-UA-Compatible" content="IE=edge">
我不想因此获得任何信誉,我只是想让更多人看到这里。
这个问题是因为页面是一个内部网站,并且IE浏览器将其兼容模式设为默认。不过,IE11仍支持addEventListener()
方法。
我的问题是我使用了es6的箭头函数=>
,而不是function ()
。
将=>
替换为function ()
后问题得到解决。
我原本以为这是一个jQuery的问题。
<meta http-equiv="x-ua-compatible" content="IE=edge">
是必须的,因为它覆盖了IE的兼容模式。<meta http-equiv="x-ua-compatible" content="IE=edge">
content="IE=edge"
。 - god_is_love
addEventListener()
方法。您当前运行在某种兼容模式下,请检查您的选项和控制台。 - Frédéric Hamidi<meta http-equiv="X-UA-Compatible" content="IE=edge">
。 - Arnaud