【问题标题】:MVC4 Bundle with a Custom-Attribute on Link-Element在链接元素上具有自定义属性的 MVC4 捆绑包
【发布时间】:2013-06-22 20:57:56
【问题描述】:

我正在使用System.Web.Optimization.Bundle 来捆绑我所有的样式表。有没有办法扩展 Bundle 类以包含自定义属性以获得以下输出?

<link href="/Content/Css/view.css" rel="stylesheet" data-class="en"/>

链接元素中包含data-class="en"

bundles.Add(new CustomStyleBundle("~/bundles/css").Include("~/content/css/en/view.css"));

【问题讨论】:

  • 您可以为不同的类打包捆绑包~/Content/css/en, ~/Content/css/xx, etc,而不是数据属性,然后有条件地包含适当的捆绑包。

标签: c# asp.net-mvc asp.net-mvc-4 bundle


【解决方案1】:

mvc4 bundle, how it is working?

可以像这样包含它。无需创建自定义捆绑包。

<link href="@System.Web.Optimization.BundleTable.Bundles.ResolveBundleUrl("~/Content/css")" rel="stylesheet" type="text/css" />

【讨论】:

  • 如何扩展调试版本?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-08-12
  • 1970-01-01
  • 2012-06-21
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多