Asp.Net MVC 4捆绑中的JavaScript错误

use*_*508 5 asp.net asp.net-mvc asp.net-mvc-4 bundling-and-minification system.web.optimization

当我在MVC 4中使用下面的Bundling时,我的应用程序会出现几个JavaScript错误,例如'jQuery undefined'

        bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
                    "~/Scripts/jquery-{version}.js",
                    "~/Scripts/jquery-ui-{version}.js",
                    "~/Scripts/jquery.unobtrusive*",
                    "~/Scripts/jquery.validate*"));
Run Code Online (Sandbox Code Playgroud)

但是,当我使用以下方法时,我的应用程序无需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*"));
Run Code Online (Sandbox Code Playgroud)

我的问题:问题是什么?

Ant*_*t P 3

这是由于您的脚本包含的顺序错误造成的。您应该确保您的 Web 优化框架版本是最新的。这个答案提供了更多细节:

/sf/answers/839714151/

以及 NuGet 包:

http://nuget.org/packages/Microsoft.AspNet.Web.Optimization