在关闭键盘或按其他地方后,如何摆脱文本输入中的光标?
这就是我所有的 TextInput:
<TextInput
style={styles.searchBar}
onChangeText={null}
placeholder={'What are you searching for?'}
underlineColorAndroid="transparent"
/>
最佳答案
我知道这个问题有点老了,但只要改进 Martin 的回答你就可以做到:
componentDidMount(){
Keyboard.addListener('keyboardDidHide', this._forceLoseFocus);
}
<TextInput ref={(component) => this._textInput = component}/>
_forceLoseFocus = () => {
this._textInput.blur();
}
测试并使用 React Native 0.55.4
关于android - 关闭键盘后 React Native TextInput 仍然具有焦点(TextInput 中的光标),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40775216/