jQuery 压缩导致错误
有人可以解释一下当我有一个运行良好且没有错误的 jquery 脚本时,然后压缩并上传它然后返回错误吗?
非常感谢。
编辑我使用 jsLint 遇到的唯一错误是:
错误:
隐含全局:$ 3,25,27,28,31,32,34,35,36,38,45,46,47,49,50,61,63, 64,65,67,71,75,79,83,87,91,94,95,96,98,101,102,103,111,113,114,115,121,123,124,125,127,130,131,132,142,144,145,146,147,148,149,150,151,152,153,154,155,171,173,174,175,177,180,181,182,192,194,195,196,197,198,199,200,201,202,214,216,217,218,220,223,224,225,234,240,241,242,243,244,245,246,247,248,249,250,251,253,254,255,256,257,258,259,260, window 7, alert 56,106,137,187,230, document 234
which is cause its in jQuery im guessing
could someone please explain when I have a jquery script which runs fine with no errors and then compress and upload it then returns errors?
Much appreciated.
EDIT The only error im getting using jsLint is:
Error:
Implied global: $ 3,25,27,28,31,32,34,35,36,38,45,46,47,49,50,61,63,64,65,67,71,75,79,83,87,91,94,95,96,98,101,102,103,111,113,114,115,121,123,124,125,127,130,131,132,142,144,145,146,147,148,149,150,151,152,153,154,155,171,173,174,175,177,180,181,182,192,194,195,196,197,198,199,200,201,202,214,216,217,218,220,223,224,225,234,240,241,242,243,244,245,246,247,248,249,250,251,253,254,255,256,257,258,259,260, window 7, alert 56,106,137,187,230, document 234
which is cause its in jQuery im guessing
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您很可能在某些行缺少语句终止符
;
,例如,即使我没有指定以下代码也可以正常运行:或者甚至是这样:
但是当您压缩它时,并且如果您忘记将该字符放置在某处,您将收到错误消息。
除了任何可能的问题之外,请确保您的脚本中没有出现这种情况。
Most likely you are missing the statement terminator
;
at some line(s), for example following code would run fine even if i don't specify that:Or even this:
But when you compress it, and you have forgot to place that character somewhere, you will receive the errors.
Make sure this is not the case in your script other than any possible issue.
可能是因为脚本中存在错误,但在脚本未压缩时不会导致任何问题。
我建议尝试在脚本上使用 jslint 来验证它是否正确。
Probably because you have errors in your script that does not cause any problems when the script is not compressed.
I recommend try using jslint on the script to verify that it is correct.
JSLint 的替代方案是 JavaScriptLint。也许也值得检查一下。您在浏览器中遇到什么错误? Firefox 的 Firebug 应该会为您提供有关错误消息的更多详细信息。
An alternative to JSLint is JavaScriptLint. May be worth checking it in that too. What errors are you getting in the browser? Firebug for Firefox should give you more details of the error message.
我不确定您使用什么来压缩 JavaScript,但我在使用 Google Closure 编译器时注意到它本身并不遵循“规则”。
给出这段代码:
在 JSLint 中没有给出任何错误(除了“隐式全局:警报 2”)
结果
如果我使用“谁需要空白”设置来压缩它,这当然是优化的 ,但现在给出了 JSLint 错误。
I'm not sure what you are using to compress your javascript, but I have noticed from using the Google Closure compiler that it doesn't following the "rules" per se.
Given this code:
which gives no errors in JSLint (except for "Implied global: alert 2")
If I compress it using the "who needs whitespace" setting, this is the result
which is of course optimized, but now gives a JSLint error.