React Native:关闭键盘并将焦点保留在 TextInput 中

ale*_*jzy 5 react-native

我已经尝试了所有方法,但是当我关闭键盘时焦点也会模糊。但是当我希望用户将信息粘贴到 TextInput 时,我不愿意显示软键盘。

<TextInput
    ref='barcodeInput'
    style={{height: 60,borderColor: '#000000', borderWidth: 1, width:300, fontSize:30}}
    underlineColorAndroid="transparent"
    onChangeText={(text) => this.setState({inputBarcode:text})}
    onSubmitEditing={this.handleSubmitEditing.bind(this)}
    keyboardType = {'numeric'}
/>
Run Code Online (Sandbox Code Playgroud)

use*_*053 -4

您应该能够使用Keyboard中的组件react-native。例如:

import { Keyboard } from 'react-native'
Keyboard.dismiss()
Run Code Online (Sandbox Code Playgroud)

焦点仍应保持在您的输入上,但软键盘将消失。