React Native如何防止键盘在文本提交时被解雇?

问题描述 投票:3回答:1

我希望能够点击键盘上的输入按钮,继续关注TextInput,并保持键盘打开。如何才能做到这一点?

关于qazxsw poi实现的答案是指触摸qazxsw poi外部的按钮而不是实际敲击键盘上的返回键。

javascript android ios react-native
1个回答
7
投票

ScrollView上执行此操作的方法是设置TextInput,然后使用TextInput作为提交处理程序而不是blurOnSubmit={false}

onSubmitEditing

按下返回键onEndEditing清除 onTextChange(input) { this.setState({ value: input }) } submitValue() { // Do things with the value ... // Then reset it so the TextInput can be reused this.setState({ value: '' }) } <TextInput blurOnSubmit={false} style={styles.inputBox} onChangeText={input => this.onTextChange(input)} onSubmitEditing={() => this.submitValue(this.state.value)} value={this.state.value} /> 的文本。

© www.soinside.com 2019 - 2024. All rights reserved.