Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/361.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 类绑定三元和非三元属性_Javascript_Html_Css_Vue.js - Fatal编程技术网

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':'']"
>