Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何使用简写在剃刀中按条件设置类?
我尝试:
<div class="submenu @{ i==Model.Active ? @:active }">...</div>
这行不通。最短的方法是什么?
您可以尝试以下语法:
<div class="submenu @(i == @Model.Active ? "active" : "")">...</div>
希望能帮助到你 !
<div class="submenu @if (i == Model.Active) { @:active }"></div>