input输入框enter键入

 this.onKeyPress(event)}
              onFocus={this.handleFocus.bind(this)}
              onBlur={this.handleBlur.bind(this)}
              />

  onKeyPress=(e)=>{
    // console.log(e);
    let keyCode = null;

    if(e.which){
      keyCode = e.which;
    }
    else if(e.keyCode) 
    {
      keyCode = e.keyCode;
    }   
    if(keyCode === 13) 
    {
      let str = this.refs.searchipt.value;
      this.props.search(str);
      // console.log(str);
      this.refs.searchipt.value = '';
      return false;
    }
    return true;
  }

你可能感兴趣的:(input输入框enter键入)