From b1a4b2633c3538c09cd34cfac045f48e0babf9d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Mon, 22 Jul 2019 09:28:10 +0800 Subject: [PATCH 1/2] . --- public/react/src/modules/tpm/NewHeader.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/public/react/src/modules/tpm/NewHeader.js b/public/react/src/modules/tpm/NewHeader.js index d698ebf95..506e70f99 100644 --- a/public/react/src/modules/tpm/NewHeader.js +++ b/public/react/src/modules/tpm/NewHeader.js @@ -393,6 +393,7 @@ class NewHeader extends Component { // } } onSearchhref = (value) => { + debugger window.location.href ="/search?value="+value; // let code = e.keyCode; @@ -727,10 +728,10 @@ submittojoinclass=(value)=>{ style={{display: 'none'}} > <Search - placeholder="实践课程/翻转课堂/开发社区/交流问答" - onSearch={(value)=>this.onSearchhref(value)} - - onPressEnter={this.onKeywordSearchKeyDown} + placeholder="实践课程/翻转课堂/开发社区/交流问答" + // onSearch={(value)=>this.onSearchhref(value)} + onSearch={value => console.log(value)} + onPressEnter={this.onKeywordSearchKeyDown} style={{ width: 300 }} /> </div> From f44cf53cb9fbcef67ecd2768666d796e069800b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Mon, 22 Jul 2019 09:58:42 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=20=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/react/src/modules/tpm/NewHeader.js | 18 ++++++++++-------- public/react/src/search/SearchPage.js | 20 +++++++++++--------- 2 files changed, 21 insertions(+), 17 deletions(-) diff --git a/public/react/src/modules/tpm/NewHeader.js b/public/react/src/modules/tpm/NewHeader.js index 506e70f99..9202dfbf4 100644 --- a/public/react/src/modules/tpm/NewHeader.js +++ b/public/react/src/modules/tpm/NewHeader.js @@ -36,7 +36,7 @@ const $ = window.$ // TODO 这部分脚本从公共脚本中直接调用 const RadioGroup = Radio.Group; -const Search = Input.Search; +const { Search } = Input; let old_url; function loadHeader(){ //头部导航条的----------显示搜索框 @@ -384,7 +384,9 @@ class NewHeader extends Component { } onKeywordSearchKeyDown = (e) => { - window.location.href ="/search?value="+e.target.value; + let url="/search?value="+e.target.value; + + this.props.history.push(url) // let code = e.keyCode; // if(code == 13) { @@ -392,9 +394,10 @@ class NewHeader extends Component { // return false; // } } - onSearchhref = (value) => { - debugger - window.location.href ="/search?value="+value; + onSearchhref = (e) => { + let url="/search?value="+e.target.value; + + this.props.history.push(url) // let code = e.keyCode; // if(code == 13) { @@ -729,10 +732,9 @@ submittojoinclass=(value)=>{ > <Search placeholder="实践课程/翻转课堂/开发社区/交流问答" - // onSearch={(value)=>this.onSearchhref(value)} - onSearch={value => console.log(value)} + onChange={(e)=>this.onSearchhref(e)} onPressEnter={this.onKeywordSearchKeyDown} - style={{ width: 300 }} + style={{ width: 300 }} /> </div> diff --git a/public/react/src/search/SearchPage.js b/public/react/src/search/SearchPage.js index 37a06e8d8..32d88b392 100644 --- a/public/react/src/search/SearchPage.js +++ b/public/react/src/search/SearchPage.js @@ -52,15 +52,6 @@ class SearchPage extends Component{ } componentDidMount(){ - // const query =this.props.location.search; - // const type = query.split('?tab='); - // let sum = [] - // sum.push(type[1]) - // // console.log("componentDidMountcomponentDidMount"); - // // console.log(sum); - // this.setState({ - // tab:sum, - // }) let courstype=decodeURI(decodeURI(this.props.location.search)); courstype = courstype.split('?value='); @@ -70,6 +61,17 @@ class SearchPage extends Component{ this.getdata(this.state.page,this.state.type,courstype[1]); } + componentDidUpdate(prevProps) { + if(prevProps.location.search!=this.props.location.search){ + let courstype=decodeURI(decodeURI(this.props.location.search)); + courstype = courstype.split('?value='); + + this.setState({ + keywords:courstype[1] + }) + this.getdata(this.state.page,this.state.type,courstype[1]); + } + } setdatafunsval=(e)=>{ this.setState({