javascript – 如何在React-Navigation中单击Bottom Tab Navigator打开DrawerNavigator?

我正在使用react-navigation并尝试在BottomTabNavigator中单击选项卡项时打开抽屉(使用DrawerNavigator).

我目前的代码看起来像这样

export default createBottomTabNavigator({
  Dashboard:{
      screen:Dashboard,
      navigationoptions:{
        tabBarLabel:'Dashboard',
        tabBarIcon:({tintColor}) => (
          <Icon name ="ios-speedometer-outline" color =
            {tintColor} size = {24} />
        )
      }
  },
  Customers:{
    screen:Customers,
    navigationoptions:{
      tabBarLabel:'Customers',
      tabBarIcon:({tintColor}) => (
        <Icon name ="ios-people-outline" color =
          {tintColor} size = {24} />
      )
    }
  },
  Invoice:{
    screen:Invoice,
    navigationoptions:{
      tabBarLabel:'Invoice',
      tabBarIcon:({tintColor}) => (
        <Icon name ="ios-copy-outline" color =
          {tintColor} size = {24} />
      )
    }
  },
  TimeTracker:{
    screen:TimeTracker,
    navigationoptions:{
      tabBarLabel:'Timetracker',
      tabBarIcon:({tintColor}) => (
        <Icon name ="ios-timer-outline" color =
          {tintColor} size = {24} />
      )
    }
  },
  More:{
   screen : More,

    navigationoptions:{
      tabBarLabel:'More',
      tabBarIcon:({tintColor}) => (
        <Icon name ="ios-menu-outline" color = {tintColor} size = {24} />
      )
    }
  }
},{
  tabBarOptions:{
    activeTintColor: 'red',
    inactiveTintColor: 'grey',
    style:{
      backgroundColor: 'white',
      borderTopWidth : 0,
      shadowOffset: {width:5,height : 3},
      shadowColor: 'black',
      shadowOpacity: 0.5,
      elevation: 5
    }
  }
})

const MyApp = createDrawerNavigator({
  Home :{
    screen : HomeScreen
  },
  Settings: {
    screen:SettingScreen
  }
})

我想点击bottomTabNavigator打开drawerNavigator.即,每当按下更多标签时,drawerNavigator都会打开.

我怎样才能做到这一点 ?

我是React-Native的新手.

解决方法:

您可以在导航选项中使用tabBarOnPress事件来修改选项卡导航单击

例如.

tabBarOnPress: (tab) => {
        //your code and other stuff 
        tab.jumpToIndex(tab.scene.index)
 }

相关文章

Android性能优化——之控件的优化 前面讲了图像的优化,接下...
前言 上一篇已经讲了如何实现textView中粗字体效果,里面主要...
最近项目重构,涉及到了数据库和文件下载,发现GreenDao这个...
WebView加载页面的两种方式 一、加载网络页面 加载网络页面,...
给APP全局设置字体主要分为两个方面来介绍 一、给原生界面设...
前言 最近UI大牛出了一版新的效果图,按照IOS的效果做的,页...