Javascript 在react JSX中禁用按钮

Javascript 在react JSX中禁用按钮,javascript,html,reactjs,Javascript,Html,Reactjs,我试图在单击按钮1后禁用多个按钮。但只有Button1被禁用,而Button2却不被禁用。 请帮忙。谢谢大家! <button disabled={this.props.submitting} className="button1" type="submit" onClick={(e)=>this._handleButton1(e)}> <IndexLink activeClassName="activeLink" to='/button1'>

我试图在单击按钮1后禁用多个按钮。但只有Button1被禁用,而Button2却不被禁用。 请帮忙。谢谢大家!

    <button disabled={this.props.submitting} className="button1" type="submit" onClick={(e)=>this._handleButton1(e)}>
        <IndexLink activeClassName="activeLink" to='/button1'>Button1</IndexLink>
    </button>

    <button disabled={this.props.submitting} className="button2" type="button" onClick={(e)=>this._handleButton2(e)}>
        <IndexLink activeClassName="activeLink" to='/button2'>Button2</IndexLink>
    </button>

因为我使用的是Redux,所以function1通过地图分派传递给道具。代码的其他部分工作正常。Button1被正确禁用,这表明我的Redux操作和还原程序正确设置了this.props.submiting。这似乎是一个HTML问题。

我找到了一个解决方案,希望与大家分享。这起作用了

render() {
    let buttons;
    if (!this.props.submitting) {
     buttons = (
        <div>
            <button className="button1" type="submit" onClick={(e)=>this._handleButton1(e)}>
               <IndexLink activeClassName="activeLink" to='/button1'>Button1</IndexLink>
            </button>

            <button className="button2" type="button" onClick={(e)=>this._handleButton2(e)}>
               <IndexLink activeClassName="activeLink" to='/button2'>Button2</IndexLink>
            </button>
        </div>
    )} else {
        buttons = (
        <div>                   
            <button disabled>Submit</button>
            <button disabled>Expenses</button>
        </div>
    )}
    return ({button})

}
render(){
让按钮;
如果(!this.props.submitting){
按钮=(
这个。_把手按钮1(e)}>
按钮1
这个。_把手按钮2(e)}>
按钮2
)}否则{
按钮=(
提交
费用
)}
返回({button})
}

无法理解此代码段,请添加更多函数定义。如果您使用按钮上的onClick事件调用
\u handleButton1
函数,那么为什么需要在提交表单时调用它。您还可以添加
把手按钮1
功能的定义
render() {
    let buttons;
    if (!this.props.submitting) {
     buttons = (
        <div>
            <button className="button1" type="submit" onClick={(e)=>this._handleButton1(e)}>
               <IndexLink activeClassName="activeLink" to='/button1'>Button1</IndexLink>
            </button>

            <button className="button2" type="button" onClick={(e)=>this._handleButton2(e)}>
               <IndexLink activeClassName="activeLink" to='/button2'>Button2</IndexLink>
            </button>
        </div>
    )} else {
        buttons = (
        <div>                   
            <button disabled>Submit</button>
            <button disabled>Expenses</button>
        </div>
    )}
    return ({button})

}