小编Cod*_*Joe的帖子

如何仅在特定屏幕(例如主屏幕)上启用抽屉导航[反应本机] [反应导航]

此问题的用例是让抽屉菜单(如“设置”)仅在“主屏幕”中可用。在“主屏幕”上可能有许多按钮链接到堆栈导航的其他屏幕,其中抽屉不可用。

主要问题是如何仅在 Stack Navigator 的特定屏幕上启用抽屉导航?在下面的示例中,抽屉在堆栈的所有页面上都可用。我尝试过gestureEnabled但没有成功:

  const StackHome = () => (
    <Stack.Navigator>
      <Stack.Screen name="Home" component={Home} />
      <Stack.Screen name="Example1" component={Example1} />
      <Stack.Screen name="Example2" component={Example2} />
    </Stack.Navigator>
  );
  <Drawer.Navigator initialRouteName="Home">
      <Drawer.Screen name="Home" component={StackHome} />
      <Drawer.Screen name="Settings" component={Settings} />
  </Drawer.Navigator>
Run Code Online (Sandbox Code Playgroud)

另一方面,如果我尝试将其作为屏幕Drawer之一Stack,那么我总是有相同的标题栏(例如“标题”)

react-native react-navigation react-navigation-drawer react-navigation-stack react-navigation-v5

3
推荐指数
1
解决办法
3962
查看次数