我有一个 Button 组件,如果状态为“true”,我想为其分配一个活动类。
<Button
onClick={this.preferenceHandler.bind(this, "straight")}
className={"col-sm-12 text-center " + (this.state.straight ? "active") }
viewStyle= "primary"
>
<h4>Straight</h4>
<i className="icon icon-ok-6"></i>
</Button>
你需要那里的错误表达式:
className={"col-sm-12 text-center " + (this.state.straight ? "active" : "") }
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句