0

我有一个堆栈导航器,用于导航到所需的任何屏幕。但我也有一个只有四个屏幕的选项卡导航器。

我想让 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)
4

1 回答 1

1

在主堆栈中添加选项卡导航器堆栈,您的所有其他屏幕都将可用。这样您就可以轻松导航到这些屏幕。

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)
于 2019-05-23T17:34:32.723 回答