首页 > 解决方案 > react-navigation 5.0 - 屏幕两侧的抽屉

问题描述

我正在尝试从屏幕的每一侧获取抽屉。

但是我无法打开右边的那个。

我尝试使用 openDrawer () 方法以及 dangerouslyGetParent () 方法。OpenDrawer () 但没有任何效果。

这是我写的代码:

const UserDrawer = createDrawerNavigator()
const UserMenu = () => (
  <UserDrawer.Navigator
    drawerType="slide"
    overlayColor="rgba(49, 70, 111, 0.75)"
    drawerPosition="right"
    >
    <UserDrawer.Screen name="Profile" component={Profile}/>
    <UserDrawer.Screen name="Company" component={Company}/>
  </UserDrawer.Navigator>
)

const DashboardDrawer = createDrawerNavigator()
const DashboardMenu = () => (
  <DashboardDrawer.Navigator
    drawerType="slide"
    overlayColor="rgba(49, 70, 111, 0.75)"
    drawerPosition="left"
    initialRouteName="Dashboard"
    >
    <DashboardDrawer.Screen name="Dashboard" component={Dashboard}/>
    <DashboardDrawer.Screen name="Enterprise" component={Enterprise}/>
    <DashboardDrawer.Screen name="Cases" component={Cases}/>
    <DashboardDrawer.Screen name="Customers" component={Customers}/>
    <DashboardDrawer.Screen name="Unpaid" component={Unpaid}/>
    <DashboardDrawer.Screen name="Payments" component={Payments}/>
    <DashboardDrawer.Screen name="Recommendations" component={Recommendations}/>
    <DashboardDrawer.Screen name="UserNavigation" component={UserNavigation}/>
  </DashboardDrawer.Navigator>
)

const AppStack = createStackNavigator()
const AppNavigation = () => (
  <AppStack.Navigator headerMode="none">
    <AppStack.Screen name="Home" component={HomeNavigation} />
    <AppStack.Screen name="Dashboard" component={DashboardNavigation} />
  </AppStack.Navigator>
)

const AppNavigationContainer = () => (
  <NavigationContainer>
    <AppNavigation />
  </NavigationContainer>
)

谢谢你的帮助。

标签: react-nativereact-navigation

解决方案


推荐阅读