更改
<button type="button"为
<button type="submit"。删除
onClick。反而做
<formclassName="commentForm" onSubmit={this.onFormSubmit}>。这应该可以单击按钮并按回车键。
onFormSubmit = e => { e.preventDefault(); const { name, email } = this.state; // send to server with e.g. `window.fetch`}...<form onSubmit={this.onFormSubmit}> ... <button type="submit">Submit</button></form>
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)