Node.js “提交类型”按钮无法在react中提交表单

Node.js “提交类型”按钮无法在react中提交表单,node.js,reactjs,forms,Node.js,Reactjs,Forms,我是一个新手,不会对我的项目结构或代码做出反应,也不会触发表单的提交事件 下面是我想从下面提到的表单调用的函数 handleSubmit = async (event) => { console.log('calling'); event.preventDefault(); const resp = await axios.get(`https://example.com/${this.state.userName}`); this.props.on

我是一个新手,不会对我的项目结构或代码做出反应,也不会触发表单的提交事件

下面是我想从下面提到的表单调用的函数

handleSubmit = async (event) => {
        console.log('calling');
    event.preventDefault();
    const resp = await axios.get(`https://example.com/${this.state.userName}`);
    this.props.onSubmit(resp.data);
    //this.setState({ userName: '' });
  };

<form onSubmit={this.handleSubmit}>
      <input 
      type="text" 
      value={this.state.userName}
      onChange={event => this.setState({ userName: event.target.value })}
      placeholder="GitHub username" 
      required 
    />
    <button>Add card</button>
    </form>
当我启动服务器并尝试提交表单时,我尝试了各种方法,如下所述

<input type='submit'/> 
<button onClick='submit'> Submit </button>
Click没有调用处理程序函数。有人能帮我看一下并带我到这里吗

另外,react中的表单是否有其他替代方法,比如使用div标记? 您可以在-

处检查所有代码,但忘记添加 在按钮上键入class='submit'

抱歉,如果格式不正确,但我正在使用手机

<form onSubmit={this.handleSubmit}> 
///code
 <button type='submit'>Add card<button>     
</form>

嗨,图卡拉姆。与其只是通过github链接添加整个代码,不如使用SO工具添加相关的代码堆栈。对不起,我们下次会注意使用该选项尝试,包括,但它不起作用