问题描述
在我的本机应用程序中,我有两个堆栈导航器,它们都嵌套在抽屉导航中。
“登录”屏幕上有一个导航到主页的按钮,而主屏幕上有一个导航到“登录”的按钮; onPress={() => props.navigation.navigate('ScreenName')}
。
最初,当我按下按钮启动应用程序时,我收到错误消息
未由有效负载{“ name”:“ Login”}处理的操作'NAVIGATE'由 任何导航器。
但是,如果我一次导航从抽屉式登录,那么该按钮将起作用,并且我可以从首页导航至登录,也可以从登录导航至首页。
const Drawer = createDrawerNavigator();
const Stack = createStackNavigator<StacksParamList>();
const MainStackScreens = () => (
<Stack.Navigator initialRouteName="Home">
<Stack.Screen name="Home" component={Home} />
</Stack.Navigator>
);
const LoginRegisterScreens = () => (
<Stack.Navigator initialRouteName="Login" />
<Stack.Screen name="Login" component={Login} />
<Stack.Screen name="Register" component={Register} />
</Stack.Navigator>
);
// and the App component returns
<NavigationContainer>
<Drawer.Navigator initialRouteName="MainScreens" >
<Drawer.Screen name="MainScreens" component={MainStackScreens} />
<Drawer.Screen
name="LoginRegisterScreens"
component={LoginRegisterScreens}
options={{swipeEnabled: false}}
/>
</Drawer.Navigator>
</NavigationContainer>
仅供参考:我划分登录和注册屏幕的原因是,在这两个屏幕上禁用了滑动操作(打开的抽屉菜单)。似乎在V5中,只能从抽屉式屏幕选项中禁用它,而不能从堆栈屏幕选项中禁用它。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)