Reactjs - html 元素中的 js



在我的项目中,我有一个按钮,我想使用状态禁用它。

<Button 
color='success' 
onClick={this.changeForm}
block
disabled
>
LOGIN
</Button>

我正在使用Reactstrap。我在state中设置了一个flag值。如果flag设置为TRUE,我想禁用该按钮。所以,我想出了这个代码:

<Button 
color='success' 
onClick={this.changeForm}
block
{this.state.flag && 'disabled'}
>
LOGIN
</Button>

我越来越Syntax Error.我知道这是一个不正确的语法,那么我如何才能实现我想要的功能?

disabledButton的道具。因此:

<Button 
color='success' 
onClick={this.changeForm}
disabled={this.state.flag}
>
LOGIN
</Button>

最新更新