亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

form表單提交數據時,keywords會替換掉之前原有的參數?

form表單提交數據時,keywords會替換掉之前原有的參數?

開滿天機 2018-07-23 21:54:07
如題:這樣的情況怎么解決好呢?,然道寫一個提交前處理keywords再拼接上去的方法?代碼:<form acceptCharset="gbk" method="get" action="https:xxx_search.htm?product=true&tags=123" >                 <div className="searchBar">                   <input className="searchVal" placeholder="輸入關鍵詞搜索"                    value={this.state.value} name="keywords"                     onChange={event => {                       this.setState({                         value: event.target.value,                       });                     }} />                  <button className="searchBtn" type="submit">搜索</button>                 </div>               </form>
查看完整描述

2 回答

?
瀟湘沐

TA貢獻1816條經驗 獲得超6個贊

<form action="https:xxx_search.htm">
    <input type="hidden" name="product" value="true"/>
    <input type="hidden" name="tags" value="123"/>
    <input className="searchVal" placeholder="輸入關鍵詞搜索" 
                  value={this.state.value} name="keywords"
                    onChange={event => {
                      this.setState({
                        value: event.target.value,
                      });
                    }} /></form>


查看完整回答
反對 回復 2018-07-29
?
當年話下

TA貢獻1890條經驗 獲得超9個贊

不用form表單的默認提交,用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="輸入關鍵詞搜索" 
            value={this.state.value} name="keywords"
            onChange={event => {                this.setState({                    value: event.target.value,
                });
            }} />
        <button className="searchBtn" onClick={this.search}>搜索</button>
    </div>
}


查看完整回答
反對 回復 2018-07-29
  • 2 回答
  • 0 關注
  • 909 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號