我正在使用官方的react-navigation来处理我的导航。我有一个用于整个应用程序的主 TabNavigator,有两个选项卡(称为HitchhikingMapNavigator
和SettingsNavigator
下面),每个选项卡都有一个嵌套的 StackNavigator:
const HitchhikingMapNavigator = StackNavigator({
hitchhikingMap: { screen: HitchhikingMapViewContainer },
spotDetails: { screen: SpotDetailsViewContainer }
}, {
navigationOptions: {
header: {
visible: false
}
}
});
const SettingsNavigator = StackNavigator({
// some other routes
});
export default AppNavigator = TabNavigator({
hitchhikingMap: { screen: HitchhikingMapNavigator },
settings: { screen: SettingsNavigator }
}, {
navigationOptions: {
header: {
visible: false,
},
},
});
如您所见,即使在我看来,我也将标题的可见性设置为 false HitchhikingMapViewContainer
:
class HitchhikingMapView extends React.Component {
static navigationOptions = {
title: 'Map',
header: {
visible: false,
},
//...other options
}
然而,标题栏仍然可见:
如果我不嵌套导航器(即,如果我放置此代码,则跳过嵌套的):
export default AppNavigator = TabNavigator({
hitchhikingMap: { screen: HitchhikingMapViewContainer },
settings: { screen: SettingsNavigator }
});
然后标题被正确隐藏。
所以结论:当我有两个嵌套导航器时,我不能使标题不可见。有任何想法吗?