修改ScriptBundle 生成顺序
ScriptBundle 一般用法
C#的代码如下:
bundles.Add(new ScriptBundle("~/bundles/jqueryval") .
Include("~/Scripts/modernizr-*", "~/Scripts/json2.js", "~/Scripts/columnizer.js", "~/Scripts/jquery.ui.message.min.js", "~/Scripts/Shared/achievements.js", "~/Scripts/Shared/canvas.js")
);
> OrderFiles(BundleContext context, IEnumerable<BundleFile> files) { return files; } } 然后按照下面的代码修改
public class BundleConfig
{
public static void RegisterBundles(BundleCollection bundles)
{
var bundle = new Bundle("~/bundles/scripts/canvas");
bundle.Orderer = new AsIsBundleOrderer();
bundle.Include("~/Scripts/modernizr-*",
"~/Scripts/json2.js",
"~/Scripts/columnizer.js",
"~/Scripts/jquery.ui.message.min.js",
"~/Scripts/Shared/achievements.js",
"~/Scripts/Shared/canvas.js");
bundles.Add(bundle);
}
}
此时看看生成的页面,是不是脚本的引入顺序的变化?脚本能正确执行了!
转自http://blog.csdn.net/pipi0714/article/details/37502123