当我使用下面的MVC 4捆绑,我的应用程序获得了几个JavaScript错误,如“jQuery的未定义JavaScript错误在Asp.Net MVC 4捆绑
bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
"~/Scripts/jquery-{version}.js",
"~/Scripts/jquery-ui-{version}.js",
"~/Scripts/jquery.unobtrusive*",
"~/Scripts/jquery.validate*"));
但是当我使用下面的方法,我的应用程序工作没有JavaScript错误:
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*"));
我的问题:是什么问题?
在调试模式下,各个脚本标签是否按正确的顺序添加? – jrummell 2013-03-15 14:24:52
听起来像脚本正在被包含在错误的顺序。这个答案表明它可能是您正在使用的Web优化框架的版本:http://stackoverflow.com/a/11995916/1043198 – 2013-03-15 14:29:22
@AntP非常感谢,我更新到Microsoft.AspNet.Web.Optimization版本1.1 .0-Beta1现在我的应用程序可以正常工作。 – user197508 2013-03-15 15:27:33