【问题标题】:react native drawer navigation drag drawer from left to right didn't work从左到右反应本机抽屉导航拖动抽屉不起作用
【发布时间】:2019-08-04 08:18:33
【问题描述】:

抽屉导航有问题。我不能从左到右拖动抽屉,当我用按钮打开抽屉时,我不能按抽屉外面来关闭它。

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

这是我想要实现的目标:

这是我的代码:

    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】:

确保您正确安装和链接react-native-gesture-handler。您可以找到如何安装它here(在 android 上还有一些步骤。请务必小心操作)。同样在HomenavigationOptions 中,drawerLockMode 设置为locked-closed,这意味着您不能使用手势来打开或关闭抽屉。从this 你应该将它设置为unlocked

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-09-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多