我正在尝试处理安卓上的后退按钮,因为我的React Native应用程序在根screen...Is的后退按钮上有自定义逻辑,任何像Navigation.getCurrentRoutes()这样的方法都可以这样做:
handleBackButton = () => {
if(Navigation.getCurrentRoutes().size()>1) {
return true; // addEventListener listens for the native hardware back button press and will ignore it
}
... customLogic
return false; // will execute the native back press (and exit the app)
} “反应-本机导航”:"3.0.0-alpha.2“
发布于 2019-12-12 19:57:13
事实证明没有这样的方法,有两个选项: 1)自己处理后退按钮(重写);2)只需将您的自定义逻辑添加到componentWillUnmount()中,并继续使用原生的react- native导航
选项2适用于我
参考:https://github.com/wix/react-native-navigation/pull/4226#issuecomment-433683885 https://github.com/wix/react-native-navigation/issues/4231
https://stackoverflow.com/questions/59285082
复制相似问题