首页 > 代码库 > react input 获取/失去焦点

react input 获取/失去焦点

<div className={ this.state.focus ? "dis_bottom_left_onfocus" : "dis_bottom_left" } ref="bottom_left">
<input
type="text"
className="dis_bottom_input"
ref="bottom_input"
placeholder={this.props.mainName || "说点什么吧"}
onBlur={ ::this.inputOnBlur }
onFocus={ ::this.inputOnFocus } />
</div>

//input 获取焦点 width: 100%
inputOnFocus(){
this.setState({ focus: true });
}

//input 失去焦点
inputOnBlur(){
this.setState({ focus: false });
}

react input 获取/失去焦点