我正尝试从我的一个名为“个人资料”的标签中打开抽屉,如下所示。当我单击配置文件选项卡时,它将从ProfileNavigator打开主屏幕。没错,但是我想防止这种情况,只打开抽屉而没有默认导航。我该怎么做?另外,ProfileNavigator阻止打开我的下一个选项卡,即“主页”,为什么?但是我可以在Histroy屏幕上选择标签,然后可以返回到主屏幕。
const ProfileNavigator = createDrawerNavigator({
Home: {
screen: HomeScreen,
},
Notifications: {
screen: ExampleScreen,
}
});
const DashboardTabNav = createBottomTabNavigator({
Profile: {
screen: ProfileNavigator,
navigationOptions: ({navigation}) => ({
tabBarOnPress: (tab) => {
navigation.openDrawer();
}
})
},
Home: Dashboard,
History: SettingsScreen,
Cart: CartScreen
})
答案 0 :(得分:0)
啊,修复它。 如果有人找一个例子, 您需要在createBottomTabNavigator中添加createDrawerNavigator。反之,我正在这样做。 例如,
const ProfileNavigator = createDrawerNavigator({
Drawer: DashboardTabNav
}, {
initialRouteName: 'Drawer',
contentComponent: ExampleScreen,
drawerWidth: 300
});
// Manifest of possible screens
const PrimaryNav = createStackNavigator({
DashboardScreen: { screen: ProfileNavigator },
LoginScreen: { screen: LoginScreen },
LaunchScreen: { screen: LaunchScreen },
UpdateUserScreen: { screen: UpdateUserScreen }
}, {
// Default config for all screens
headerMode: 'none',
initialRouteName: 'LoginScreen',
navigationOptions: {
headerStyle: styles.header
}
});
export default createAppContainer(PrimaryNav);