在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問答/HTML/ form表單提交數(shù)據(jù)時(shí),keywords會(huì)替換掉之前原有的參數(shù)?

form表單提交數(shù)據(jù)時(shí),keywords會(huì)替換掉之前原有的參數(shù)?

如題:這樣的情況怎么解決好呢?,然道寫一個(gè)提交前處理keywords再拼接上去的方法?

代碼:

<form acceptCharset="gbk" method="get" action="https:xxx_search.htm?product=true&tags=123" >
                <div className="searchBar">
                  <input className="searchVal" placeholder="輸入關(guān)鍵詞搜索" 
                  value={this.state.value} name="keywords"
                    onChange={event => {
                      this.setState({
                        value: event.target.value,
                      });
                    }} />
                  <button className="searchBtn" type="submit">搜索</button>
                </div>
              </form>
回答
編輯回答
久舊酒

不用form表單的默認(rèn)提交,用fetch或者axios異步提交

search(){
    const {value} = this.state;
    fetch(`https:xxx_search.htm?product=true&tags=123&keywords=${value}`).then(...)
}
render(){
    // ...
     <div className="searchBar">
        <input
            className="searchVal"
            placeholder="輸入關(guān)鍵詞搜索" 
            value={this.state.value} name="keywords"
            onChange={event => {
                this.setState({
                    value: event.target.value,
                });
            }} />
        <button className="searchBtn" onClick={this.search}>搜索</button>
    </div>
}
2018年5月29日 21:40
編輯回答
病癮
<form action="https:xxx_search.htm">
    <input type="hidden" name="product" value="true"/>
    <input type="hidden" name="tags" value="123"/>
    <input className="searchVal" placeholder="輸入關(guān)鍵詞搜索" 
                  value={this.state.value} name="keywords"
                    onChange={event => {
                      this.setState({
                        value: event.target.value,
                      });
                    }} />
</form>
2017年4月23日 15:22