无法弄清楚如何获得预期的结果。我尝试了什么? 我将react-native和所有其他依赖项更新为最新版本。 我查看了反应导航文档,甚至为此在github上创建了一个错误。
我做错什么了吗?我在使用TabNavigation时需要设置标题标题
const RootNavigator = createStackNavigator({
...publicScreens,
Private: {
screen: PrivateNavigator
}
}, publicScreensConfig);
const privateScreens = {
ContactList: {
screen: ContactList
},
Settings: {
screen: Settings
}
};
.....
export default createBottomTabNavigator( privateScreens, options );
import React, { Component } from 'react'
import { Text, View } from 'react-native'
import GlobalColors from '../../config/colors';
export default class Settings extends Component {
static navigationOptions = {
title: 'Settings',
headerStyle: {
backgroundColor: GlobalColors.grayDark,
},
headerTintColor: 'white',
headerTitleStyle: {
fontWeight: 'bold',
},
gesturesEnabled: false,
}
render() {
return (
<View>
<Text> Settigs </Text>
</View>
)
}
}
但是我看到标题是空的。 我想查看来自导航选项的标题文本
答案 0 :(得分:0)
感谢JinHoSo在这里
const bottomTabNavigator = createBottomTabNavigator(...)
bottomTabNavigator.navigationOptions = ({navigation, screenProps}) => {
const childOptions = getActiveChildNavigationOptions(navigation, screenProps)
return {
title : childOptions.title,
headerLeft : childOptions.headerLeft,
headerRight: childOptions.headerRight,
}
}