在 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
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章