我在使用 React-Native js 框架开发带有导航的应用程序时遇到了问题。我有一个 StackNavigator,它可以在登录页面和主页之间导航。但我不想让用户在按下电话按钮或通过屏幕栏上的按钮导航时导航回登录页面,而不注销
有没有办法拒绝 StackNavigator 导航回登录页面?
最佳答案
如果我理解正确的话,一旦您确定登录成功,您需要做的就是通过 Reset Navigation Action. 重置堆栈
import { NavigationActions } from 'react-navigation'
const resetAction = NavigationActions.reset({
index: 0,
actions: [
NavigationActions.navigate({ routeName: 'Profile'})
]
})
this.props.navigation.dispatch(resetAction)
您的路线名称,我认为是“家”或类似的名称。
如果您想通过重置整个内容来返回注销状态,您将拥有 to pass null to the key param .
关于javascript - 有没有办法让 StackNavigator 无法导航回页面?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48250422/