我仍然是 React 的新手,并且很难弄清楚如果 props 返回 true 时如何显示 div 元素内容。我知道我只能在函数中返回一个渲染,但我该如何实现。我可以编写一些类型的 Jsx 内联 if 语句吗?
<div>if true show</div>
<div>if true show</div>
<div>false don't show</div>
<div>if true show</div>
更新:我实际用过
{this.props.test === true &&
<div>if true show</div>
}
最佳答案
现在的简单用例。
{this.props.test === true &&
<div>if true show</div>
}
关于javascript - 如果为真,则 react 显示这些 div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43991224/