[英]How to debug: Change from div to form element in React. No response
我嘗試在react渲染中從div
更改為form
元素(使用type="submit"
),但是沒有響應。 它顯示http://localhost:3000/ ?
僅供參考, div
工作正常。 代碼如下:
<div className="SearchBar">
<input placeholder="Enter A Song, Album, or Artist" onChange={this.handleTermChange} />
<a onClick={this.handleSearch}>SEARCH</a>
</div>
===
<form className="SearchBar" onSubmit={this.handleSearch}>
<input placeholder="Enter A Song, Album, or Artist" onChange={this.handleTermChange} />
<button type="submit">SEARCH</button>
</form>
Github倉庫在這里 。
感謝您的時間。
您的提交可能正在屏幕上刷新。
在函數的開頭使用e.preventDefault()及其handleSearch函數
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.