【问题标题】:Showing TabBar in DrawerNavigator screen在 DrawerNavigator 屏幕中显示 TabBar
【发布时间】:2018-05-17 23:38:01
【问题描述】:

我目前有这个结构:

const Tabs = TabNavigator({
  Home: {screen: Home},
  Store:{screen: Store}
  More: {screen: More,
    navigationOptions: {
      tabBarLabel: 'More',
      tabBarIcon: <Entypo name='dots-three-horizontal' size={25}/>,
      header: null
      },
    }
  },
  {
  initialRouteName: 'Home',
  tabBarPosition: 'bottom',
  navigationOptions: ({ navigation }) => ({
            tabBarOnPress: (scene, jumpToIndex) => {
                if (scene.route.routeName === "More") {
                  navigation.navigate('DrawerToggle')
                }
                else{
                  jumpToIndex(scene.index);
                }
            },
        }),
      },
    )


const Drawer = DrawerNavigator(
  {
   Tabs: {screen: Tabs,
     navigationOptions: {
           drawerLabel: () => null
      }
   },
   Profile: {screen: Profile},
   Search: {screen: Search}
  },
  {
   initialRouteName: 'Tabs',
   headerMode: 'none',
   drawerPosition: 'right'
  }
)


export const Root = StackNavigator(
  {
  LoginScreen: {screen: Login},
  Drawer: {screen: Drawer},
 },
  {
   initialRouteName: 'LoginScreen'
  }
)

一切都很好。当我点击(例如)“个人资料”时,页面正常加载,点击“更多”时,抽屉菜单打开。

我想实现的功能是我想在“个人资料”页面(DrawerNavigator 屏幕)内显示 TabBar。这怎么可能?

【问题讨论】:

    标签: reactjs react-native react-navigation tabnavigator stack-navigator


    【解决方案1】:
    const Drawer = DrawerNavigator(
      {
       Profile: {screen: Tabs},
       Search: {screen: Search}
      }
    

    您可以将导航器嵌套在另一个导航器中。选项卡导航器是一个组件,您可以将该组件用作不同导航器的“屏幕”。

    导航器是一个组件。屏幕必须是一个组件。

    【讨论】:

    • 嘿,感谢您的回答,但个人资料屏幕应该是个人资料(个人资料页面)而不是标签。我在 Tabnavigator 中添加了配置文件屏幕,当单击 DrawerNavigator 中的配置文件时,我被重定向到配置文件页面。我可以看到下面的 TabBar(这就是我最初想要的),我唯一的问题是我想从 TabBar 隐藏“配置文件”选项卡。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-11-14
    • 1970-01-01
    • 2020-07-10
    • 1970-01-01
    • 2021-05-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多