如何在React中使用POST方法提交表单输入数据?

时间:2019-03-13 12:03:34

标签: javascript node.js reactjs

我当前正在使用html文件将表单输入数据发布到我的节点/表达后端。

代码:

<body>
  <form action="/signup" method="POST">
    <input
      type="text"
      name="firstName"
      id="first-name"
      placeholder="First Name"
    />

    <div class="form-group">
      <input
        type="text"
        name="lastName"
        id="last-name"
        placeholder="Last Name"
      />
    </div>

    <div class="form-group">
      <input type="email" name="email" id="email" placeholder="Email" />
    </div>

    <button type="submit">Sign Up</button>
  </form>
</body>

与html文件中的方法类似,使用POST方法的React方法是什么?

谢谢。

1 个答案:

答案 0 :(得分:0)

我认为这就是您要寻找的How to make a rest post call from ReactJS code?

使用主体传递表单参数。

相关问题