javascript - 如何在 React-Navigation 中单击底部选项卡导航器时打开 DrawerNavigator?
问题描述
我正在使用react-navigation
并尝试在单击BottomTabNavigator
.
我当前的代码看起来像这样
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
}
})
我想在底部TabNavigator 的点击上打开drawerNavigator。即,每当按下更多选项卡时,drawerNavigator 就会打开。
我怎样才能做到这一点 ?
我是 React-Native 的新手。
解决方案
you can use tabBarOnPress event in navigation options to modify tab navigation click
eg.
tabBarOnPress: (tab) => {
//your code and other stuff
tab.jumpToIndex(tab.scene.index)
}
推荐阅读
- google-colaboratory - Colab Notebook 崩溃/重启周期,在升级到 Colab Pro 2 天后出现自动保存失败和“无效凭据”
- iis - 使用 appcmd 设置 IIS10 网站的物理路径
- excel - excel,检查字符串是否包含字符 az 或 AZ
- java - Postgres 点类型列到 Spring Entity 数据类型
- node.js - 缺少节点方法?
- nginx - 如何设置nginx位置
- c# - 为什么我在运行管道时收到错误消息?
- android - 菜单中的 onOptionsItemSelected 对于使用 actionLayout 的项目是不可点击的
- java - 在线程 java.lang.RuntimeException 中获取异常:在同一阶段更改场景时 java.lang.reflect.InvocationTargetException
- java - 如何计算数组列表中的元素重复?