【发布时间】:2016-11-10 14:32:18
【问题描述】:
我的反应渲染中有这个 javascript:
<p id='canPlay'>
{this.state.canPlayArray.map(function(num, index){
return <p key={ index }>Name: {num.name} Date Indicated: {num.dateConfirmed}</p>;
}, this)}
</p>
但有时,canPlayArray 可能为空。我怎么能说如果 array.length >0 然后渲染数组 ELSE 显示'没有人响应'
我不能在我认为的 html 中执行 if/else 并且在 return() 之前我有:
if (this.state.info){
output = <Thanks />;
}
这可能会阻止我在那里执行 if/else?
考虑使用三元运算符,但不知道放在哪里
【问题讨论】:
标签: javascript html reactjs