MVC-1.1 BundleConfig-ScriptBundle

App_Start中的BudleCnfig.cs中

bundles.Add(new ScriptBundle("~/bundles/jquery").Include(



"~/Scripts/jquery-{version}.js"));



 



bundles.Add(new ScriptBundle("~/bundles/jqueryui").Include(



"~/Scripts/jquery-ui-{version}.js"));



 



bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(



"~/Scripts/jquery.unobtrusive*",



"~/Scripts/jquery.validate*"));



            

 

 

            

        可以看出用到了{version} 和* 匹配的文件名来加载js库,

        然后自己完全可以写几个自定义的bundles

        MVC-1.1 BundleConfig-ScriptBundle

     

  bundles.Add(new ScriptBundle("~/myBundles/myJqueryUi").Include(



"~/Scripts/MyTmpl/jquery-ui-{version}.js"



));



bundles.Add(new ScriptBundle("~/myBundles/myJquery").Include(



"~/Scripts/MyTmpl/jquery-{version}.js"



));



bundles.Add(new ScriptBundle("~/myBundles/myJquery").Include(



"~/Scripts/MyTmpl/jquery.{name}.js"



));



 



bundles.Add(new ScriptBundle("~/myBundles/allJquery").Include(



"~/Scripts/MyTmpl/jquery*"



)); 

 

 

  2,视图中引用即可:

           

 @Scripts.Render("~/myBundles/allJquery"); 

 

 

 

       3,查看浏览器加载:

            MVC-1.1 BundleConfig-ScriptBundle

         加载了全部文件,

            

 

你可能感兴趣的:(script)