在 ReactJS 中获取表单数据 - Get form data in ReactJS

问题:

I have a simple form in my render function, like so:我的render函数中有一个简单的表单,如下所示:

render : function() {
      return (
        <form>
          <input type="text" name="email" placeholder="Email" />
          <input type="password" name="password" placeholder="Password" />
          <button type="button" onClick={this.handleLogin}>Login</button>
        </form>
      );
    },
handleLogin: function() {
   //How to access email and password here ?
}

What should I write in my handleLogin: function() { ... } to access Email and Password fields?我应该在我的handleLogin: function() { ... }写什么handleLogin: function() { ... }以访问EmailPassword字段?


解决方案:

参考一: https://en.stackoom.com/question/1aIX2
参考二: https://stackoom.com/question/1aIX2
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章