简体   繁体   English

React Navigation V5 在 Stack Navigator 中隐藏底部标签栏

[英]React Navigation V5 hide Bottom tab bar in Stack Navigator

I have found many different solutions, but unfortunately none of them work.我找到了许多不同的解决方案,但不幸的是它们都不起作用。 I have a Stack Navigator and a Tabbar Navigator.我有一个 Stack Navigator 和一个 Tabbar Navigator。 I have a profile page.我有一个个人资料页面。 Now I want that when you press a button that another screen opens - I managed that.现在我希望当您按下另一个屏幕打开的按钮时 - 我做到了。 But unfortunately I have the annoying tabbar also in this screen.但不幸的是,我在这个屏幕上也有烦人的标签栏。 How do I get rid of it?我该如何摆脱它? I think this should work, but React Navigation don't recommend it:我认为这应该可行,但 React Navigation 不推荐它:

if (route.state && route.state.index > 0) {
  navigation.setOptions({tabBarVisible: false})
} else {
  navigation.setOptions({tabBarVisible: true})
}

You need to create a main stack navigator, which will handle the main routing.您需要创建一个主堆栈导航器,它将处理主路由。 Then, you need to create another tab navigator and then pass it to the stack screens where you want the tab navigator.然后,您需要创建另一个选项卡导航器,然后将其传递到您想要选项卡导航器的堆栈屏幕。 You could try something similar to this https://reactnavigation.org/docs/nesting-navigators/您可以尝试类似于此https://reactnavigation.org/docs/nesting-navigators/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM