react-native - 是否可以在屏幕中显示标签栏但标签栏中不显示屏幕?

标签 react-native react-navigation

让我有三个屏幕。

  1. 首页
  2. 简介
  3. 设置

当应用程序启动时,主屏幕将显示两个选项卡(配置文件和设置)。我已经将 react-navigation 用于选项卡导航器。单击配置文件选项卡时,将显示配置文件屏幕,如果单击设置选项卡,将显示设置屏幕。

最佳答案

您可以将导航对象添加到另一个屏幕。我尝试根据您的需要创建示例代码

const HomeScreen = createTabNavigator({
  HomeScreen: { 
    screen: HomeScreen,
    navigationOptions: {
        header: null,
        tabBarLabel: 'Profile',
        tabBarOnPress: ({ navigation }) => {
               navigation.navigate('Profile')  
        }
    }
  },
  Settings: { 
    screen: Settings,
    navigationOptions: {
        header: null
    }
  },



},

{
    initialRouteName: 'HomeScreen',
    lazy: true,
})
const HomeScreen = createStackNavigator({
  Profile: { 
    screen: Profile,
    navigationOptions: {
        header: null
    }
  },
  Home: { 
    screen: Home,
    navigationOptions: {
        header: null
    }
  },



},

{
    initialRouteName: 'Home',
    lazy: true,


})

关于react-native - 是否可以在屏幕中显示标签栏但标签栏中不显示屏幕?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45035562/

相关文章:

React-Native Stack 导航器返回到具有相同初始路由名称的上一个屏幕

android - 在 react native 项目中安装 react-navigation 后出现警告

javascript - 如何在 React Native 的一个功能组件中同时使用 props 和 navigation

android - 使用全屏主题时,React Native 'Modal' 组件未覆盖 Android 上的整个屏幕

android - react native android 键盘事件

ios - 错误 : undefined is not an object (evaluating \'RCTWebSocketManager.connect\' )

reactjs - 如何在 const 中使用 react 导航?

javascript - 在 monorepo 中共享 typescript 库

android - 如何编写一个简单的带有回调的 react-native 原生模块

android - BackHandler 无法正常工作 React Native