如果我点击一个输入字段,那么他们的键盘是激活的。如果我想要通过单击移除键盘,我可以使用以下命令:
<TouchableWithoutFeedback onPress={Keyboard.dismiss()}
...好的,但也许键盘是打开的,我想单击一个具有onPress函数的框或项。因此,如果键盘是打开的,也许我想单击一个链接,那么键盘会关闭,但该链接没有被按下。当键盘打开时,我不能点击任何东西,现在我想让你问我如何点击一个链接,也许在键盘打开的地方。也许是像"TouchableWithFeedBack“这样的函数。
这和你可以找到用户的Instagram是一样的。如果键盘是打开的,而您想要单击此人,它将转到User,然后他们将键盘关闭。在我的情况下,只有键盘可以忽略。
我希望你能理解我
发布于 2021-04-14 05:22:19
当您添加其他项(链接或按钮)作为TouchableWithoutFeedback组件的子项时,交互似乎工作得很好:
import * as React from 'react';
import { Alert, Keyboard, TouchableWithoutFeedback, TextInput, Button, View, StyleSheet } from 'react-native';
export default function App() {
return (
<TouchableWithoutFeedback onPress={Keyboard.dismiss}>
<View style={styles.container}>
<Button title="Press Me" onPress={() => Alert.alert('Button Pressed')} />
<TextInput placeholder="Input" autoFocus />
</View>
</TouchableWithoutFeedback>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
padding: 8,
},
});https://stackoverflow.com/questions/67082373
复制相似问题