我目前正在尝试通过条件将 class.bind
属性与基本 html class
组合到 html 组件中。喜欢:
<a href="#" class="stackpanel stretch" class.bind="myCondition == true ? 'myClass' :''">
我想得到(如果 myCondition = true
):
<a href="#" class="stackpanel stretch myClass">
你能告诉我最好的方法是什么吗?
最佳答案
您不需要指定 class.bind
和 class
,您可以在 class 中使用插值语法和普通类
属性。
<a href="#" class="stackpanel stretch ${myCondition == true ? 'myClass' : ''}">
关于html - 在 Aurelia 中将 class.bind 与 HTML 元素中的 native 类结合起来,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50968016/