捆绑(优化)的样式是';浏览器无法识别
本文关键字:浏览器 识别 优化 样式 捆绑 | 更新日期: 2023-09-27 18:20:19
我试图在asp.net MVC4项目中使用Bundle,当它处于调试模式时一切正常,但当我尝试使用优化模式时,会发生一些奇怪的事情。
这是我的捆绑包配置:
bundles.Add(new ScriptBundle("~/content/admin/css").Include("~/Content/css/AdminPage.css",
"~/Content/MarkItUp/MarkItUp.css",
"~/Content/MarkItUp/style.css",
"~/Content/jqTreeThemes/apple/style.css",
"~/Content/css/popup_window.css",
"~/Content/css/fullcalendar.css",
"~/Content/jHtmlArea/jHtmlArea.css"));
这就是我在页面上使用它的方式:
@section header
{
@Styles.Render("~/content/admin/css");
}
所以,当我使用时
BundleTable.EnableOptimizations = true;
例如,Firefox将样式作为脚本,我可以在FireBug的Net选项卡中看到这一点。(http://grab.by/nZ0Y)
这就是为什么我的跟踪没有任何影响。
有人能解释一下我的原因吗?
不要使用ScriptBundle
(用于脚本),而是使用StyleBundle
(用于样式)。
bundles.Add(new StyleBundle("~/content/admin/css").Include("~/Content/css/AdminPage.css","~/Content/MarkItUp/MarkItUp.css","~/Content/MarkItUp/style.css","~/Content/jqTreeThemes/apple/style.css","~/Content/css/popup_window.css","~/Content/css/fullcalendar.css","~/Content/jHtmlArea/jHtmlArea.css"));