【发布时间】:2018-05-22 10:21:44
【问题描述】:
我正在做出反应。我想在单击按钮时显示文本框,并尝试显示有关聚焦文本框的建议。所以我尝试了OnFocus() 事件,当我们点击文本框时我想隐藏建议,所以我使用了onBlur() 事件。当我手动聚焦文本框时,它工作正常。
当我尝试在单击按钮时自动聚焦时,也会触发 onBlur() 并隐藏建议。我不知道为什么。帮我解决这个问题。
代码:
<input type="text" tabIndex="1" onFocus={//focus handler//} placeholder="Enter Search value" ref="search_txt" onBlur={this.onBlurEvent} />
componentDidMount(){
this.refs.search_txt.focus();
}
【问题讨论】:
-
能否提供完整代码,对您有帮助
标签: reactjs