【问题标题】:Stop style bundling adding xml closing停止样式捆绑添加 xml 关闭
【发布时间】:2016-01-12 12:49:28
【问题描述】:

使用 mvc 样式包时:

@Styles.Render("~/content/site")

它总是会用一个自结束标签来渲染你的样式表:

<link href="/Content/Site.css" rel="stylesheet"/>

有没有办法阻止这种情况?

【问题讨论】:

    标签: asp.net-mvc asp.net-mvc-5 bundling-and-minification


    【解决方案1】:

    使用@Styles.RenderFormat:

    @Styles.RenderFormat(@"<link href=""{0}"" rel=""stylesheet""></link>",
                          "~/content/site")
    

    【讨论】:

    • 如果你这样做,它会渲染包中所有单独的样式表吗?
    • 显然,是的。请参阅我编辑的代码。文档 (msdn.microsoft.com/en-us/library/…) 要求第二个参数是虚拟路径
    • 非常好,正是我需要的。谢谢!
    猜你喜欢
    • 2019-01-30
    • 2012-12-16
    • 2016-09-05
    • 2018-11-09
    • 2012-09-24
    • 1970-01-01
    • 2012-03-19
    • 1970-01-01
    • 2018-08-13
    相关资源
    最近更新 更多