我有一个堆栈导航器,用于导航到所需的任何屏幕。但是我也有一个标签导航器,上面只有四个屏幕。
我想在除登录和创建屏幕以外的每个屏幕上显示Tab Navigator。
我尝试了很多组合这些变体,但似乎没有任何作用
const stackNav = createStackNavigator({
Login: {
screen: LoginScreen
},
Scan: {
screen: ScanScreen
},
Search: {
screen: SearchScreen
},
Product: {
screen: ProductScreen
},
Create: {
screen: CreateScreen
},
Home: {
screen: HomeScreen
},
Profile: {
screen: ProfileScreen
}
}, {
headerMode: 'none',
defaultNavigationOptions: {
gesturesEnabled: false
}
})
const tabNav = createBottomTabNavigator({
HomeTab: {
screen: HomeScreen,
},
ScanTab: {
screen: ScanScreen,
},
SearchTab: {
screen: SearchScreen,
},
ProfileTab: {
screen: ProfileScreen,
}
})
export default createAppContainer(stackNav)
在主堆栈中添加选项卡导航堆栈,您的所有其他屏幕将可用。这样您就可以轻松导航到这些屏幕。
const tabNav = createBottomTabNavigator({
HomeTab: {
screen: HomeScreen,
},
ScanTab: {
screen: ScanScreen,
},
SearchTab: {
screen: SearchScreen,
},
ProfileTab: {
screen: ProfileScreen,
}
})
const stackNav = createStackNavigator({
Login: {
screen: LoginScreen
},
Create: {
screen: CreateScreen
},
// Tab Navigator screens
Home: {
screen : tabNav
}
},
{
headerMode: 'none',
defaultNavigationOptions: {
gesturesEnabled: false
}}
);
export default createAppContainer(stackNav)