【问题标题】:Inline Razor conditional statement that will only display html attribute and value if condition is met内联 Razor 条件语句,仅在满足条件时显示 html 属性和值
【发布时间】:2018-01-11 06:06:20
【问题描述】:

无论如何我可以更改这个内联剃须刀条件语句,以便类属性不总是输出到 html,除非实际添加了类。我不希望我的 html 中包含 class=""。

<div id="wrapper" class="@(isMobile ? "mobileView" : "")">

【问题讨论】:

    标签: c# asp.net asp.net-mvc razor asp.net-core-mvc


    【解决方案1】:

    怎么样

    <div id="wrapper" @(isMobile ? "class=\"mobileView\"" : "")>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多