【发布时间】:2018-09-25 17:39:14
【问题描述】:
我是 react.js 的新手。我正在尝试从表单中收集值。我阅读了从谷歌搜索中找到的几个 SO 问题和文章。我现在很困惑。 在 react.js 中从 Form 中收集值的实际方法是哪一种? 我读了this SO 问题。我在这里找到了
<input type="text" name="email" placeholder="Email" value={this.state.email} onChange={this.handleEmailChange} />
我阅读了this 的文章,发现下面的代码
<input type="text" name="fname" value={fname} onChange={this.onChange} />
在 Facebook 群组中,成员建议我使用 this。
我应该走哪条路?我应该使用state 吗?
【问题讨论】:
-
你需要使用第一种方法
标签: reactjs