我有一些数据可以通过以下方式访问:
{{ content['term_goes_here'] }}
... 这个数值估计为true
或false
.我想根据表达式的真实性添加一个类,如下所示:
<i class="fa" v-bind:class="[{{content['cravings']}} ? 'fa-checkbox-marked' : 'fa-checkbox-blank-outline']"></i>
true
给我fa-checkbox-marked
级,false给我fa-checkbox-blank-outline
级.我在上面写的方式给了我一个错误:
- invalid expression: v-bind:class="[{{content['cravings']}} ? 'fa-checkbox-marked' : 'fa-checkbox-blank-outline']"
How should I write it to be able to conditionally determine the class?