asp.net-mvc-4 – 如何配置MVC的样式捆绑顺序?
我的网络应用程序正在使用一个设置有jquery-ui和jqgrid的大图标。
为了容易地保持对CSS的更改以适应更大的图标,当升级jquery-ui或jqgrid我有一个单独的CSS文件,我有一堆覆盖。 你可以想象这个覆盖文件必须包含在jquery-ui样式表和jqgrid样式表之后。 我把所有的样式表都整理成一个捆绑包 bundles.Add(new StyleBundle("~/Content/dark-hive/allstyles").Include( "~/Content/dark-hive/jquery-ui-1.8.23.custom.css","~/Content/ui.jqgrid.css","~/Content/jquery-ui-fixes.css","~/Content/icons.css","~/Content/site.css")); 但它被渲染如此! <link href="/Content/dark-hive/jquery-ui-1.8.23.custom.css" rel="stylesheet"/> <link href="/Content/jquery-ui-fixes.css" rel="stylesheet"/> <link href="/Content/ui.jqgrid.css" rel="stylesheet"/> <link href="/Content/icons.css" rel="stylesheet"/> <link href="/Content/site.css" rel="stylesheet"/> 如何配置我的包以正确的顺序呈现? 更新 无论我做了什么,文件总是呈现不正确的。所以我尝试了一些愚蠢的,最后添加了jquery-ui-fixes.css和jquery-ui-1.8.23.custom.css。 突然我的命令是 <link href="/Content/jquery-ui-fixes.css" rel="stylesheet"/> <link href="/Content/dark-hive/jquery-ui-1.8.23.custom.css" rel="stylesheet"/> <link href="/Content/ui.jqgrid.css" rel="stylesheet"/> <link href="/Content/icons.css" rel="stylesheet"/> <link href="/Content/site.css" rel="stylesheet"/> 我将我的javascript文件重命名为jqueryuifixes.css,现在它的顺序保存在较低的js文件中。 我在想,如果一个样式表有一个名称,它首先被优先排列某些原因,它的顺序与其他文件一起维护。 如果有人可以解释这个,我会给他们支票。 解决方法
如果您单独包含每个文件,则捆绑包将会尊重您的订单…
var bundle = new Bundle("~/Content/dark-hive/allstyles",new StyleBundle()); bundle.Include("~/Content/dark-hive/jquery-ui-1.8.23.custom.css"); bundle.Include("~/Content/ui.jqgrid.css"); bundle.Include("~/Content/jquery-ui-fixes.css"); bundle.Include("~/Content/icons.css"); bundle.Include("~/Content/site.css"); bundles.Add(bundle); UPDATE 即使使用明确的顺序,您会发现有一个非常方便的内置订购系统,首先在所有其他订单系统上订购特定的命名文件。要完全清除这一点,您可以使用: bundles.FileSetOrderList.Clear(); 您可以使用以下方式添加自己的定制订单: BundleFileSetOrdering ordering = new BundleFileSetOrdering("My Order"); ordering.Files.Add("jquery.js"); bundles.FileSetOrderList.Clear(); bundles.FileSetOrderList.Add(ordering); 本质上,有一个庞大的内置文件列表,在任何不在列表中的任何文件之前,它们将被放入一个特定的顺序 – 但这些选项可以让你控制。 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
- asp.net-mvc – ASP.NET MVC UpdateModel空属性
- asp.net – 如何将数据绑定表达式的值存储到变量中
- asp.net – 从标签容器中的数据绑定gridview丢失更新面板触
- 即使在完成所有可能的设置后,使用IIS 7在asp.net 2.0中超时
- 可用.net控件库的比较
- asp.net-mvc-3 – 使用Ninject 2.2的MVC 3依赖注入将全局操
- asp.net-mvc – Asp.Net MVC Html助手扩展
- 如何使用AutoMapper将多个OBJECTS映射到一个对象 – asp.ne
- asp.net – 移动设备的CSS有时会恢复原状
- asp.net – WebMethod以JSON格式返回值