【发布时间】:2023-03-10 19:30:01
【问题描述】:
【问题讨论】:
标签: android react-native keyboard
【问题讨论】:
标签: android react-native keyboard
当<TextField /> 获得焦点时,键盘应该会自动打开。当元素挂载link 时,您可以使用autoFocus 属性使其成为焦点
另外,你可以检查这个答案
How to open keyboard automatically in React Native?
顺便说一下,你想为此控制硬件返回按钮,访问这个链接
React Native - Device back button handling
这里是硬件后退按钮的示例代码。
import { BackHandler } from 'react-native';
constructor(props) {
super(props)
this.handleBackButtonClick = this.handleBackButtonClick.bind(this);
}
componentWillMount() {
BackHandler.addEventListener('hardwareBackPress', this.handleBackButtonClick);
}
componentWillUnmount() {
BackHandler.removeEventListener('hardwareBackPress', this.handleBackButtonClick);
}
handleBackButtonClick() {
this.props.navigation.goBack(null);
return true;
}
【讨论】: