简体   繁体   English

JavaScript无法在生产环境中使用

[英]Javascript not working in Production

I've deployed my app in production and precompiled the assets pipeline, so my application.js contains everything. 我已经在生产环境中部署了我的应用程序,并预编译了资产管道,所以我的application.js包含了所有内容。

while it was all working fine in development (where files were split) it's not working any more in production, and tooltips and everything don't work any more. 尽管在开发中一切正常(将文件拆分了),但在生产环境中却无法正常工作,并且工具提示和所有内容均无法正常工作。

the only problem I'm seeing in chrome console is: 我在chrome控制台中看到的唯一问题是:

Uncaught TypeError: Cannot read property 'msie' of undefined 

it mentions the line containing the error: 它提到包含错误的行:

jquery.js:9789

although the application.js (precompiled) at line 9789 is blank, and in my source I don't include explicitly any source file called jquery.js , as the jquery is included inside the application.js . 尽管9789行的application.js(预编译)为空白,但在我的源代码中我没有明确包含任何名为jquery.js源文件,因为jquery包含在application.js

I found that jquery_bbq may be the problem, in I run: grep -r msie * I have only two occurrences: 我发现jquery_bbq可能是问题所在,在我运行时: grep -r msie *我只有两次出现:

config/recipes/templates/nginx_configuration.erb
vendor/assets/javascripts/jquery_ba-bbq.min.js

I'm not sure how to troubleshoot this, any ideas ? 我不确定如何解决此问题,有什么想法吗?

thanks in advance 提前致谢

Something you're including is trying to read the msie property of jQuery.browser . 你包括一些试图读取msie财产jQuery.browser But jQuery doesn't have the jQuery.browser symbol any more (it was deprecated in v1.3 and removed in v1.9). 但是jQuery不再具有jQuery.browser符号(在v1.3中已弃用,在v1.9中已删除)。

I can't account for the line number other than to mention that jQuery 1.10.2, un-minified, has exactly that many lines. 除了提及jQuery 1.10.2(未缩小)具有这么多行外,我无法说明行号。 As for the filename, I assume your HTML or something in your application.js or another script you're loading is loading jquery.js . 至于文件名,我假设您的HTML或您的application.js或正在加载的其他脚本中的某些内容正在加载jquery.js Chrome's Network tab in the dev tools should tell you what's loading jquery.js . 开发工具中的Chrome的“网络”标签应告诉您正在加载jquery.js

So the solution is to find out what plug-in or similar you're using that's trying to use jQuery.browser.msie (or $.browser.msie ) and deal with the fact it's no longer compatible with jQuery. 因此,解决方案是找出正在使用的插件或类似插件,这些插件正在尝试使用jQuery.browser.msie (或$.browser.msie ),并处理与jQuery不再兼容的事实。 You've already basically done that and found jquery_ba-bbq.min.js 您已经基本做到了,找到了jquery_ba-bbq.min.js

The other thing is to find and deal with whatever's including jquery.js , if you have jQuery baked into your application.js (presumably an older version, if this was working before you combined things). 另一件事是查找和处理包括jquery.js在内的所有内容(如果您已将jQuery烘焙到application.js (大概是一个较旧的版本,如果在合并之前还可以使用的话))。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM