JavaScript错误在Asp.Net MVC 4捆绑 [英] JavaScript Error in Asp.Net MVC 4 Bundling
问题描述
当我用下面MVC 4捆绑,我的应用程序可以获得多个JavaScript错误,如jQuery的未定义
When I use the below Bundling in MVC 4, my App gets several JavaScript errors,such as 'jQuery undefined'
bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
"~/Scripts/jquery-{version}.js",
"~/Scripts/jquery-ui-{version}.js",
"~/Scripts/jquery.unobtrusive*",
"~/Scripts/jquery.validate*"));
但是,当我用下面的方法,我的应用程序工作没有JavaScript错误:
But when I use the below approach, my App works without JavaScript errors:
bundles.Add(new ScriptBundle("~/bundles/jquery1").Include(
"~/Scripts/jquery-{version}.js"));
bundles.Add(new ScriptBundle("~/bundles/jquery2").Include(
"~/Scripts/jquery-ui-{version}.js"));
bundles.Add(new ScriptBundle("~/bundles/jquery3").Include(
"~/Scripts/jquery.unobtrusive*"));
bundles.Add(new ScriptBundle("~/bundles/jquery3").Include(
"~/Scripts/jquery.validate*"));
我的提问:有什么问题。
推荐答案
这是由脚本引起包括在错误的顺序。你应该确保你的网络优化框架的版本是最新的最新的。这个答案提供进一步的细节:
This is caused by your scripts being included in the wrong order. You should ensure that your version of the Web Optimization Framework is up-to-date. This answer provides further details:
<一个href=\"http://stackoverflow.com/a/11995916/1043198\">http://stackoverflow.com/a/11995916/1043198
和中的NuGet包:
http://nuget.org/packages/Microsoft.AspNet.Web.Optimization
这篇关于JavaScript错误在Asp.Net MVC 4捆绑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!