Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 按backspace时,React语义UI输入未触发功能_Javascript_Reactjs - Fatal编程技术网

Javascript 按backspace时,React语义UI输入未触发功能

Javascript 按backspace时,React语义UI输入未触发功能,javascript,reactjs,Javascript,Reactjs,我正在使用语义UI构建表单。 如果我的某个按钮未执行,我将禁用“提交”按钮 <Button disabled={!merchantId || !conduit || !region || !acquirer || !processingTimezone} content={`Associate to Domain ${DomainData.domain}`} onClick={() => this.submitNewMerchant()} /> this.s

我正在使用语义UI构建表单。 如果我的某个按钮未执行,我将禁用“提交”按钮

<Button
   disabled={!merchantId || !conduit || !region || !acquirer || !processingTimezone}
   content={`Associate to Domain ${DomainData.domain}`}
   onClick={() => this.submitNewMerchant()}
/>
this.submitNewMerchant()}
/>
我用一个函数来改变每个字段的状态

// other inputs
<Form.Input
   name="processingTimezone"
   onKeyDown={() => console.log('backspace')}
   onChange={e => this.inputChange(e)}
   label="processingTimezone" 
   defaultValue={processingTimezone}
/>


inputChange = (event) => {
  const { name, value } = event.target;
  this.setState({ [name]: value });
}
//其他输入
console.log('backspace')}
onChange={e=>this.inputChange(e)}
label=“processingTimezone”
defaultValue={processingTimezone}
/>
inputChange=(事件)=>{
常量{name,value}=event.target;
this.setState({[name]:value});
}
正如您所看到的,我正在尝试使用onChange和onKeyDown跟踪用户输入,但是如果用户聚焦一个输入,选择all(ctrl+a)并按Backspace,就会出现问题。 未将状态更新为空或“”或任何其他值


如何管理此操作?

尝试向输入文本添加值:

<Form.Input
      name="processingTimezone"
      onKeyDown={() => console.log('backspace')}
      onChange={e => this.inputChange(e)}
      label="processingTimezone" 
      defaultValue="CST"
      value={this.state.processingTimezone}
    />
console.log('backspace')}
onChange={e=>this.inputChange(e)}
label=“processingTimezone”
defaultValue=“CST”
值={this.state.processingTimezone}
/>

如果状态不变,至少输入不会改变。

代码对我来说很好。@nithin你在哪里测试?你有链接吗?其他按键的状态更新了吗?是的,他们更新得很正确。