|
@@ -9,7 +9,8 @@ class ScaleSearch extends Component {
|
|
|
this.$inp = React.createRef();
|
|
|
this.$cont = React.createRef();
|
|
|
this.state={
|
|
|
- val:''
|
|
|
+ val:'',
|
|
|
+ hasSearch: false
|
|
|
};
|
|
|
this.search = this.search.bind(this);
|
|
|
this.handleChange = this.handleChange.bind(this);
|
|
@@ -43,6 +44,11 @@ class ScaleSearch extends Component {
|
|
|
});
|
|
|
}
|
|
|
search(){
|
|
|
+ if(this.state.hasSearch === false){
|
|
|
+ this.setState({
|
|
|
+ hasSearch: true
|
|
|
+ })
|
|
|
+ }
|
|
|
const {handleChangeValue} = this.props;
|
|
|
const val = this.$inp.current.value;
|
|
|
handleChangeValue&&handleChangeValue(val);
|
|
@@ -61,7 +67,8 @@ class ScaleSearch extends Component {
|
|
|
const {clearResult} = this.props;
|
|
|
this.$inp.current.value = '';
|
|
|
this.setState({
|
|
|
- val:''
|
|
|
+ val:'',
|
|
|
+ hasSearch: false
|
|
|
});
|
|
|
clearResult&&clearResult();
|
|
|
}
|
|
@@ -77,7 +84,7 @@ class ScaleSearch extends Component {
|
|
|
}
|
|
|
render() {
|
|
|
const {searchResult} = this.props;
|
|
|
- const {val} = this.state;
|
|
|
+ const {val, hasSearch} = this.state;
|
|
|
return (
|
|
|
<div className={style['search-cont']} ref={this.$cont}>
|
|
|
<div className={style['search-box']}>
|
|
@@ -93,7 +100,7 @@ class ScaleSearch extends Component {
|
|
|
<ul>
|
|
|
{this.getSearchList()}
|
|
|
</ul>
|
|
|
- </div>:<p className={style['no-data']}>暂无搜索结果!</p>}
|
|
|
+ </div>:hasSearch && <p className={style['no-data']}>暂无搜索结果!</p>}
|
|
|
</div>
|
|
|
)
|
|
|
|