diff --git a/public/react/src/modules/tpm/NewHeader.js b/public/react/src/modules/tpm/NewHeader.js index d698ebf95..844268c34 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,8 +394,10 @@ class NewHeader extends Component { // return false; // } } - onSearchhref = (value) => { - 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) { @@ -727,11 +731,10 @@ submittojoinclass=(value)=>{ style={{display: 'none'}} > this.onSearchhref(value)} - - onPressEnter={this.onKeywordSearchKeyDown} - style={{ width: 300 }} + placeholder="实践课程/翻转课堂/开发社区/交流问答" + // onSearch={(e)=>this.onSearchhref(e)} + onPressEnter={this.onKeywordSearchKeyDown} + style={{ width: 300 }} /> 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({