手势已启用:false在React Native中无效

wixjitnu  于 2022-12-19  发布在  React
关注(0)|答案(3)|浏览(189)

"我在用"

"@react-navigation/native": "^5.0.5",
"@react-navigation/stack": "^5.2.8",

代码

const RankingStack = createStackNavigator(
  {
    Ranking,
  },
  {
    initialRouteName: 'Ranking',
    headerMode: 'none',
    navigationOptions: {
      title: 'ranking',
      gesturesEnabled: false,
    },
  },
);

const AppNavigator = createStackNavigator({
  RankingStack,
}, {
  mode: 'card',
  headerMode: 'none',
  initialRouteName: 'Loading',
});

我不知道为什么这个gesturesEnabled: false不工作。
如果你能给我提些建议,我将不胜感激。

qybjjes1

qybjjes11#

尝试不带**“s”的gestureEnabled:false?**
@LPFJ尝试后更新,其工作方式如下:

const AppNavigator = createStackNavigator({
  RankingStack,
}, {
  mode: 'card',
  headerMode: 'none',
  initialRouteName: 'Loading',
  defaultNavigationOptions: {
    gestureEnabled: false
  }
});

文件

nnsrf1az

nnsrf1az2#

shout out to @高鵬翔

const AppNavigator = createStackNavigator({
  RankingStack,
}, {
  mode: 'card',
  headerMode: 'none',
  initialRouteName: 'Loading',
  defaultNavigationOptions: {
    gestureEnabled: false
  }
});

这起作用了!

58wvjzkj

58wvjzkj3#

我的包版本:

"@react-navigation/native": "6.0.10",
"@react-navigation/native-stack": "6.6.2",

为了禁用后退手势,您需要做一件棘手的事情。您需要添加
手势启用:假的
导航器和屏幕

<Stack.Navigator screenOptions={{ gestureEnabled: false }}/>
  <Stack.Screen 
    options={{gestureEnabled: false}}
    component={YourScreenWithoutGesture}
  />
  <Stack.Screen 
    component={YourScreenWithGesture}
  />
<Stack.Navigator />

在我看来,这是应该改变的,因为它是非常违反直觉和误导...

相关问题