gpt4 book ai didi

javascript - 关闭键盘后禁用 TextInput

转载 作者:行者123 更新时间:2023-11-30 19:53:27 30 4
gpt4 key购买 nike

使用 React Native TextInput,在键盘可见的情况下点击后退按钮(屏幕截图中的红色 1)时,可以稍后编辑 TextInput 值。但是,当点击检查/输入图标(屏幕截图中的红色 2)时,键盘消失后无法更改 TextInput。之后点击输入时,插入符号会在点击过程中出现,但随后消失,没有任何反应。

enter image description here

这是我的组件:

export class MyInput extends Component {
constructor (props) {
super(props);
this.state = {
inputValue: `${Date.now()}-document`,
};

this.onFocus = this.onFocus.bind(this);
}
onFocus (text) {
if (this.placeholderRemoved) {
return text;
}
this.textInput.clear();
this.placeholderRemoved = true;

return '';
}
render () {
return (
<KeyboardAvoidingView>
<TextInput
value={this.state.inputValue}
onChangeText={(text) => {
this.setState({inputValue: text});
}}
/>
</KeyboardAvoidingView>
);
}
}

测试:

  • 小米 Pocophone F1,Android 8.1
  • Google Pixel 2(模拟器),Android 7.1.1

enter image description here

如何在关闭键盘后启用对 TextInput 的编辑?

根据@Sean Wang 的要求进行编辑

import React, {Component} from 'react';
import {AppRegistry, View} from 'react-native';
import {MyInput} from './myInputViewComponent';

export default class myApp extends Component {
render() {
return (
<View>
<MyInput />
</View>
);
}
}

AppRegistry.registerComponent('myApp', () => myApp);

"react": "16.7.0", "react-native": "0.57.6",

最佳答案

我能够重现您的问题,这确实是 RN 版本 0.57.6 的问题.因此,在这种情况下,您的解决方案是使用 RN 版本 0.57.7或稍后,这个问题应该得到解决。

这进一步确认为 0.57.6 的发布日志声明在 TextInput 中引入了问题这是固定的 0.57.7等等。

引用:https://github.com/facebook/react-native/releases/tag/v0.57.6

关于javascript - 关闭键盘后禁用 TextInput,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54255053/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com