【问题标题】:I am trying to hide the back arrow navigation button but it does not work我试图隐藏后退箭头导航按钮,但它不起作用
【发布时间】:2021-05-05 15:18:58
【问题描述】:

大家好,我想隐藏后退箭头导航按钮,但它不起作用

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>
  )
}

【问题讨论】:

  • 这是一项简单的任务,文档中已提供,请在此处提问之前更正确地查看它。我已经在下面发布了答案

标签: javascript reactjs react-native react-navigation-v5 react-navigation-stack


【解决方案1】:

在您的&lt;Stack.Screen&gt;&lt;Stack.Navigator&gt; 选项中设置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>
  )
}

【讨论】:

  • headerLeft: null 不适合我。相反,我使用了一个空视图:headerLeft: () =&gt; { return &lt;View style={{ marginLeft: 50 }}&gt;&lt;/View&gt;; }
猜你喜欢
  • 2012-04-21
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-07-03
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多