【发布时间】:2017-03-28 05:49:51
【问题描述】:
我知道如何使用这样的三元运算符:
{ this.state.showThanks ? 'Thanks for your response!' : null }
但我想渲染 html,然后在点击时删除该 html
{ this.state.showThanks ? <input type="submit" className="decisionButtons" id="canDecisionButton" value="I can play" onClick={() => this.canPlay()}/>
<input type="submit" className="decisionButtons" id="cantDecisionButton" value="I cannot play" onClick={() => this.cannotPlay()}/>
: 'Thanks for your response!' }
我尝试了类似上述的方法,但出现错误,那么如何在我的 react 渲染方法中将 html 放置在三元组中?
【问题讨论】:
标签: html reactjs render ternary