jQuery IE9-10:无法获取未定义或空引用的属性替换 [英] jQuery IE9-10: unable to get property replace of undefined or null reference

查看:438
本文介绍了jQuery IE9-10:无法获取未定义或空引用的属性替换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用以下库开发页面;

I'm developing a page with the following libraries;

  • jQuery(1.7.2)(较旧的版本,因为存在依赖性问题,但已尝试使用1.9.1或更高版本,无法解决问题).
  • 骨干(1.1.0)
  • lodash(2.4.1)
  • modernizr(2.7.1)
  • gsap(1.17.0)

页面使用canvas和gsap进行动画处理.一切都可以在IE11,Chrome,Safari,Firefox和IE8(适用于IE8的动画)中运行良好,但是IE9和10只会在控制台中抛出该错误,并且

The page use canvas and gsap for animation. Everything works great in IE11, Chrome, Safari, Firefox, and IE8 (animations disabled for IE8), but IE9 and 10 just throw this error in the console over and

无法获取未定义或空引用的属性替换"

unable to get property 'replace' of undefined or null reference

所引用的行在jquery.js的第622行中,这是此代码中的return语句:

The line referenced is in jquery.js, line 622, which is the return statement in this code:

// Convert dashed to camelCase; used by the css and data modules
// Microsoft forgot to hump their vendor prefix (#9572)
camelCase: function( string ) {
    return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
},

我不知道如何确定我的代码的哪一部分导致此jQuery代码触发,因此我不确定到底是什么问题.

I can't figure out how to determine what part of MY code caused this jQuery code to fire, so I'm unsure as to what may be the issue on my end.

有人知道这个解决方法吗?或者,如何查看代码的哪一部分导致此jquery代码触发(使用IE开发工具)?

Does anyone know a fix for this? Or alternatively, how I can view what part of my code caused this jquery code to fire (using IE dev tools)?

推荐答案

事实证明,该问题并不是IE固有的问题,而是我正在尝试访问一个尚未完全存在的对象.其他浏览器不是问题(也许他们的JS引擎足够快,不会成为问题),但是我现在添加了检查以确保在执行有问题的功能和问题之前已加载所有相关内容似乎不见了.谢谢您的帮助.

Turns out the issue wasn't something inherently wrong with IE, but rather I was trying to access an object which didn't entirely exist yet. The other browsers this was not an issue (perhaps their JS engines were just fast enough for it to be a non-issue), but I've now added checks to ensure all the relevant content has loaded before executing the problematic function and the issue seems to be gone. Thanks for the help, all.

这篇关于jQuery IE9-10:无法获取未定义或空引用的属性替换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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