StackNavigator里面的DrawNavigator里面的StackNavigator做出反应原生

时间:2017-10-21 14:59:28

标签: reactjs react-native navigation react-navigation slidingdrawer

我有一个登录页面,在用户登录后有一个TabNavigator屏幕,点击其中一个TabNavigator图标后,应该打开DrawerNavigator菜单。

const Tabs = TabNavigator({
  Home: {
    screen: Home,
    navigationOptions: {
      tabBarLabel: 'Home',
      tabBarIcon: <Image source={require('../assets/images/nav-home.png')} style={{height:25,width:25}}/>,
      header: null
    }
  },
  Store: {
    screen: Store,
    navigationOptions: {
      tabBarLabel: 'Store',
      tabBarIcon: <Image source={require('../assets/images/nav-store.png')} style={{height:25,width:25}}/>,
      header: null
    },
  },
  Other: {
    screen: DrawerNav,
    navigationOptions: {
      tabBarLabel: 'Profile',
      tabBarIcon: <Image source={require('../assets/images/nav-profile.png')} style={{height:25,width:25}}/>,
      header: null
    },
  }

},{
initialRouteName: 'Home'
})

const DrawerNav = DrawerNavigator({
  Profile: {screen: Profile},
  Search: {screen: Search},
})



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

此代码给出了一个错误:

enter image description here

当用户点击其他菜单时,屏幕应从左侧滑入,其中包含个人资料 搜索退出(与Slack应用程序一样),当用户点击例如个人资料屏幕时,他们将被重定向到该页面。这怎么可能?

1 个答案:

答案 0 :(得分:0)

您只需将“const DrawerNav”移动到“const Tabs”上方即可。 之后它会起作用