我目前正在实现一个小型React Native应用,这是我目前拥有的导航器:
const RootNav= createStackNavigator(
{
Login: LogInScreen,
},
);
const TabNav = createBottomTabNavigator(
{
Home: { screen: HomeScreen },
Calendar: { screen: CalendarScreen },
Discussion: { screen: DiscussionScreen },
Profile: { screen: ProfileScreen },
},
);
export const SwitchNav = createSwitchNavigator(
{
AuthLoading: AuthLoadingScreen,
Auth: RootNav,
MainApp: TabNav,
},
{
initialRouteName: 'AuthLoading',
},
);
现在,在HomeScreen和CalendarScreen中,有几个Card
组件应导航到名为EventScreen
的另一个屏幕,并具有返回到上一个屏幕的选项,该选项应该是另一个createStackNavigator
想,但我仍然需要帮助,以正确的方式设置导航器。预先感谢。
答案 0 :(得分:0)
您可以有一个StackNavigator
和EventScreen
作为其子项的父项TabNav
:
const RootNav = createStackNavigator(
{
Login: LogInScreen,
}
);
const HomeNav = createStackNavigator(
{
tabNav: TabNav,
Events: { screen: EventScreen },
}
);
const TabNav = createBottomTabNavigator(
{
Home: { screen: HomeScreen },
Calendar: { screen: CalendarScreen },
Discussion: { screen: DiscussionScreen },
Profile: { screen: ProfileScreen },
}
);
export const SwitchNav = createSwitchNavigator(
{
AuthLoading: AuthLoadingScreen,
Auth: RootNav,
MainApp: HomeNav,
},
{
initialRouteName: 'AuthLoading',
}
);
如果您觉得将来也需要DrawerNavigation
,那么现在就好好处理它是个好主意。 This article可能会有帮助。