【问题标题】:how to get drawer over header in react navigation v5?如何在反应导航 v5 中将抽屉放在标题上?
【发布时间】:2020-02-24 07:12:05
【问题描述】:

这是我的代码

export const DrawerStack = () => {
  return (
<Drawer.Navigator
      drawerStyle={{backgroundColor: BLUE_COLOR_1}}
      drawerContentOptions={{labelStyle: {color: '#FFF'}}}>
      <Drawer.Screen
        name={HOME_SCREEN}
        component={HomeTopTabNavigator}

      />
      <Drawer.Screen
        name={WALLET}
        component={Wallet}
        options={{title: 'Wallet'}}
      />...

然后我在堆栈屏幕中引用它,我将其包装在堆栈导航器中

<Stack.Navigator><Stack.Screen
        name={HOME_STACK_SCREEN}
        component={DrawerStack}

我尝试关注How to get drawer over the header in react navigation?,但这些很快将无法在 v5 中使用,因为导航器无法将另一个导航器作为直接子级

【问题讨论】:

    标签: react-native react-navigation-v5


    【解决方案1】:

    你需要把你的堆栈放在抽屉里,而不是把抽屉放在堆栈里

    - Drawer
      - Stack
        - Home
        - Wallet
    

    https://reactnavigation.org/docs/en/nesting-navigators.html#parent-navigators-ui-is-rendered-on-top-of-child-navigator

    v5 作为导航器不能有另一个导航器作为直接子级

    你不需要直接的孩子。将堆栈放在屏幕内。

    【讨论】:

    • 你能显示一些代码吗?我访问了您提到的网址,但我不明白
    猜你喜欢
    • 2018-10-22
    • 2020-06-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-08-26
    • 1970-01-01
    • 2016-01-22
    • 1970-01-01
    相关资源
    最近更新 更多