gpt4 book ai didi

javascript - React Native 中的 KeyboardAvoidingView 不显示键盘

转载 作者:行者123 更新时间:2023-12-02 23:10:46 24 4
gpt4 key购买 nike

我想知道如何在 React Native 中使用键盘。

当我点击输入内容(“发送”)时,没有键盘显示。

enter image description here

我尝试使用“KeyboardAvoidingView”,但键盘不显示。

ChatScreen.js

import React from 'react';
import { ScrollView, KeyboardAvoidingView, StyleSheet, Text, View } from 'react-native';
import MessageList from './MessageList';
import MessageForm from './MessageForm';

export default class ChatScreen extends React.Component {
render() {
return (
<KeyboardAvoidingView style={styles.container} behavior="padding" enabled>
<MessageList />
<MessageForm />
</KeyboardAvoidingView>
);
}
}

const styles = StyleSheet.create({
container: {
display: 'flex',
flexDirection: 'column',
flexGrow: 1,
backgroundColor: 'grey',
alignSelf: 'stretch',
},
});

MessageForm.js

import React from 'react';
import { StyleSheet, Text, View, TextInput } from 'react-native';
import MessageFormStyles from './MessageFormStyles'

export default class MessageForm extends React.Component {
render() {
return (
<View style={MessageFormStyles.container}>
<TextInput
style={MessageFormStyles.input}
placeholder="Send">

</TextInput>
</View>
);
}
}

Package.json

"dependencies": {
"axios": "0.19.0",
"expo": "31.0.2",
"react": "16.5.0",
"react-native": "https://github.com/expo/react-native/archive/sdk-32.0.0.tar.gz",
"react-native-gesture-handler": "^1.3.0",
"react-native-vector-icons": "^6.6.0",
"react-navigation": "3.11.1",
"react-redux": "6.0.1",
"redux": "4.0.4",
"redux-devtools-extension": "2.13.8",
"redux-immutable-state-invariant": "^2.1.0",
"redux-thunk": "^2.3.0"
},

你知道为什么我看不到键盘吗?

最佳答案

如果您使用模拟器,则必须在模拟器硬件设置中禁用键盘。

请去切换键盘,您可能会再次看到键盘

关于javascript - React Native 中的 KeyboardAvoidingView 不显示键盘,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57372466/

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