4

我使用 react-navigation 并希望将 TabNavigator 和 DrawerNavigator 一起使用。我知道你可以嵌套导航器,但是只有抽屉的一个链接有我的选项卡。

我希望标签导航始终可见,并且抽屉应该可用。

抽屉滑过标签

所以顶部的三个选项卡应该始终可见。并且抽屉可以滑出以链接不同的场景。

const CustomTabRouter = TabRouter({
  Tab1: {
    screen: Tab1,
    path: '1',
  },
  Tab2: {
    screen: Tab2,
    path: '2',
  },
  Tab3: {
    screen: Tab3,
    path: '3',
  },
}, {
  initialRouteName: 'Tab2',
})

const TabNavigation = createNavigationContainer(
  createNavigator(CustomTabRouter)(CustomTabView)
)

const AppNavigation = DrawerNavigator({
  Home: {
    screen: TabNavigation
  },
  ScreenOne: {
    screen: ScreenOne
  },
  ScreenTwo: {
    screen: ScreenTwo
  },
}, {
  headerMode: 'none',
  initialRouteName: 'Home',
  drawerPosition: 'right',
  contentComponent: props => Slider(props),
  contentOptions: {
    inactiveTintColor: Colors.primary,
    activeTintColor: Colors.orange,
    activeBackgroundColor: Colors.white
  },
})

但是我的代码的问题是选项卡仅适用于一个场景。还尝试了 StackNavigators 但必须是另一种解决方案才能同时使用两个导航器。

4

1 回答 1

0

如果您需要始终显示选项卡,则需要使用 TabNavigation 作为您的顶级路由器,并在其中嵌套其他导航选项。

于 2019-05-09T09:11:53.287 回答