我正在使用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)
}