如何修复“无法读取属性“1.0””从零开始 jQuery 问题?
我使用 rhino 1.7R2 在浏览器之外运行 JavaScript 代码来测试它。这工作正常,但是一旦测试的代码使用 jQuery,我就会收到此错误消息:
org.mozilla.javascript.EcmaError: TypeError: Cannot read property "1.0" from null (jquery.js#6313)
at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3557)
at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3535)
at org.mozilla.javascript.ScriptRuntime.typeError(ScriptRuntime.java:3563)
at org.mozilla.javascript.ScriptRuntime.typeError2(ScriptRuntime.java:3582)
at org.mozilla.javascript.ScriptRuntime.undefReadError(ScriptRuntime.java:3595)
at org.mozilla.javascript.ScriptRuntime.getObjectElem(ScriptRuntime.java:1343)
at org.mozilla.javascript.gen.c30._c1(jquery.js:6313)
在 jquery.js 的第 6313 行,我没有看到可能导致此类错误消息的代码:
6313 jQuery.extend({
任何人都知道 jquery 试图访问哪个对象的属性命名为“1.0”?我可能需要模拟这个对象,但到目前为止我无法找出 jquery 在这里尝试做什么。
I use rhino 1.7R2 to run JavaScript code outside of a browser to test it. This works fine but as soon as the tested code uses jQuery I get this error message:
org.mozilla.javascript.EcmaError: TypeError: Cannot read property "1.0" from null (jquery.js#6313)
at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3557)
at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3535)
at org.mozilla.javascript.ScriptRuntime.typeError(ScriptRuntime.java:3563)
at org.mozilla.javascript.ScriptRuntime.typeError2(ScriptRuntime.java:3582)
at org.mozilla.javascript.ScriptRuntime.undefReadError(ScriptRuntime.java:3595)
at org.mozilla.javascript.ScriptRuntime.getObjectElem(ScriptRuntime.java:1343)
at org.mozilla.javascript.gen.c30._c1(jquery.js:6313)
At line 6313 of jquery.js I don't see code which could cause such an error message:
6313 jQuery.extend({
Anyone knows on what object jquery tries to access a property named "1.0"? I probably need to mock this object but up to now I was not able to find out what jquery tries to do here.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
确保包含 jquery 文件。
Be sure you have jquery file included.
发现问题了。我只嘲笑“位置”,而不嘲笑“window.location”(或者相反,不记得了)。
Found the problem. I mocked only "location" but not "window.location" (Or the other way around, can't remember).