【发布时间】:2015-09-15 22:49:36
【问题描述】:
您应该如何有条件地添加如下所示的元素?如果withFilter 属性为真,我只希望<div className='next-field__connected-wrapper'> 存在于其中。
render: function () {
if (this.props.withFilter) {
return (
<div>
<div className='next-card next-card__section next-card__section--no-bottom-spacing'>
<div className='next-field__connected-wrapper'>
{ this.props.children }
</div>
</div>
</div>
)
} else {
return (
<div>
<div className='next-card next-card__section next-card__section--no-bottom-spacing'>
{ this.props.children }
</div>
</div>
)
}
}
【问题讨论】:
标签: javascript reactjs element prop