Javascript 类绑定三元和非三元属性
假设我有一个标签,它使用三元运算符向其添加对齐:Javascript 类绑定三元和非三元属性,javascript,html,css,vue.js,Javascript,Html,Css,Vue.js,假设我有一个标签,它使用三元运算符向其添加对齐: <td :class="alignment ? ('u-' + alignment) : null" > 如何将这两个条件保持在同一标签中?比如: /** Obviously this doesn't work */ <td :class="{ alignment ? ('u-' + alignment) : null, 'u-bright' : isBright }&
<td
:class="alignment ? ('u-' + alignment) : null"
>
如何将这两个条件保持在同一标签中?比如:
/** Obviously this doesn't work */
<td
:class="{
alignment ? ('u-' + alignment) : null,
'u-bright' : isBright
}"
>
/**显然这不起作用*/
尝试使用:
/** Obviously this doesn't work */
<td
:class="{
alignment ? ('u-' + alignment) : null,
'u-bright' : isBright
}"
>
<td
:class="[alignment ? ('u-' + alignment):'', isBright?'u-bright':'']"
>