1

如何在 Squishit 中添加动态 CSS 源路径/url?

 @Html.Raw(
        Bundle.Css()
        .Add("~/Styles/" + (ViewBag.SiteName ?? "default") + "/a.css")
        .Add("~/Styles/" + (ViewBag.SiteName ?? "default") + "/b.css")
        .Add("~/Styles/" + (ViewBag.SiteName ?? "default") + "/c.css")
        .Render("~/Styles/" + (ViewBag.SiteName ?? "default") + "/o#.css")
    ) 

这将引发错误。

4

1 回答 1

1

问题在于动态类型。

在插入之前,我首先将 ViewBag.SiteName 转换为 String 并且它起作用了。

于 2012-10-26T00:53:44.613 回答