html - 在 Aurelia 中将 class.bind 与 HTML 元素中的 native 类结合起来

标签 html css aurelia

我目前正在尝试通过条件将 class.bind 属性与基本 html class 组合到 html 组件中。喜欢:

<a href="#" class="stackpanel stretch" class.bind="myCondition == true ? 'myClass' :''">

我想得到(如果 myCondition = true):

<a href="#" class="stackpanel stretch myClass">

你能告诉我最好的方法是什么吗?

最佳答案

您不需要指定 class.bindclass,您可以在 class 中使用插值语法和普通类 属性。

<a href="#" class="stackpanel stretch ${myCondition == true ? 'myClass' : ''}">

关于html - 在 Aurelia 中将 class.bind 与 HTML 元素中的 native 类结合起来,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50968016/

相关文章:

html - 按钮显示在另一个元素上

html - HR 未在页脚居中

typescript - 如何通过 Aurelia/Typescript 导入和使用 PhotoSwipe?

javascript - Aurelia:调整大小/布局更改事件以供查看?

typescript - Aurelia - 使用 promise 的值转换器

html - 将左侧放置的跨度的 CSS 更改为 input[type=checkbox]

jquery - Bootstrap 3 按钮组 : corner radius disappears after a button is hidden

javascript - 尝试创建交互式汉堡菜单

html - css margin-top 属性仅在声明边框时有效

javascript - 我的网站不会在移动设备上滚动