React Native 我试图隐藏后退箭头导航按钮,但它不工作

pn9klfpd  于 2023-06-24  发布在  React
关注(0)|答案(2)|浏览(192)

大家好,我试图隐藏后退箭头导航按钮,但它不工作

function MyStack(){
  return(
      <Stack.Navigator
       screenOptions={{
         headerTitle:null,
         headerTransparent:true,
         topBar:{
           backButton:{
                  noBorder: true,
                  backButton: {visible: false},
                  leftButtons: [],
           }
         }
       }}
      >
      <Stack.Screen name="Index" component={IndexScreen} />
      <Stack.Screen name="drawer" component={Drawer} />
    </Stack.Navigator>
  )
}
nafvub8i

nafvub8i1#

<Stack.Screen><Stack.Navigator>选项中设置headerLeft: null,如下例所示。

function MyStack(){
  return(
      <Stack.Navigator
       screenOptions={{
         headerTitle:null,
         headerTransparent:true,
         headerLeft: null
       }}
      >
      <Stack.Screen options={{headerLeft: null}} name="Index" component={IndexScreen} />
      <Stack.Screen name="drawer" component={Drawer} />
    </Stack.Navigator>
  )
}
px9o7tmv

px9o7tmv2#

您需要在选项中设置{headerBackVisible:false}
您可以像这样将其添加到特定屏幕

<Stack.Screen options={{headerBackVisible:false}} name="Index" component={IndexScreen} />

或者你可以让它为所有的网页

<Stack.Navigator
       screenOptions={{
         headerTitle:null,
         headerTransparent:true,
         headerLeft: null,
         headerBackVisible: false,
       }}
      >

相关问题