从左到右反应原生抽屉导航拖动抽屉不起作用

问题描述 投票:0回答:1

我有抽屉导航的问题。我无法从左向右拖动抽屉,当我从按钮打开抽屉时,我无法按下抽屉外面以关闭它。

它适用于expo但不适用于react-native init

这是我想要实现的目标:

enter image description here

这是我的代码:

    const AppDrawerNavigator = createDrawerNavigator(
    {
        Home: {
            screen: Home,
            navigationOptions: {
                drawerLockMode: 'locked-closed',

                drawerIcon: (
                    <Image
                        style={{ width: 30, height: 30 }}
                        source={require('./assets/IconDrawerNavigation/home.png')}
                    />
                ),
            },
        },
        AboutUs: {
            screen: AboutUs,
            navigationOptions: {
                drawerIcon: (
                    <Image
                        style={{ width: 30, height: 30 }}
                        source={require('./assets/IconDrawerNavigation/about-us.png')}
                    />
                ),
            },
        },
        Logout: {
            screen: HomePage,
            navigationOptions: {
                drawerIcon: (
                    <Image
                        style={{ width: 30, height: 30 }}
                        source={require('./assets/IconDrawerNavigation/logout.png')}
                    />
                ),
            },
        },
    },
    {
        contentComponent: CustomDrawerComponent,
        contentOptions: {
            // activeBackgroundColor: 'red',

            labelStyle: {
                fontFamily: 'SomeFont',
                color: 'white',
            },
        },
    }
);
reactjs react-native navigation react-navigation
1个回答
1
投票

确保正确安装和链接react-native-gesture-handler。你可以找到如何安装它here(还有一些关于android的步骤。确保你仔细做)。同样在navigationOptionsHomedrawerLockMode设置为locked-closed,这意味着你不能使用手势来打开或关闭抽屉。从this你应该把它设置为unlocked

© www.soinside.com 2019 - 2024. All rights reserved.