{item.status}
<div className="{item.status !== '' ? 'hide' : ''} pull-right">Content</div>
为什么上面的jsx没有效果?我的 item.status 值是字符串。但在我的 DOM 中我看不到添加了隐藏类。
最佳答案
这是因为您已将三元运算符包装在 "中,因此它被视为字符串。请尝试以下操作:
{item.status}
<div class={"pull-right "+(item.status !== '' ? 'hide' : '')}>Content</div>
关于javascript - JXS if else 类不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42185788/