文档
一、在组件中配置(不建议)
class HomeScreen extends React.Component {
static navigationOptions = {
title: 'Home',
};
}
二、路由中配置
const AppNavigator = createStackNavigator(
{
Home: {
screen: HomePage,
navigationOptions: {
headerTitle: '网易云音乐',
headerStyle:{
backgroundColor:"#c20c0c",
},
headerTitleStyle:{
color:"#fff"
}
}
},
},
)
三、跨页面共享导航条配置
const AppNavigator = createStackNavigator(
{
Home: {
screen: HomePage,
navigationOptions: {
headerTitle: '网易云音乐',
//不需要返回按钮
headerLeft:null
}
},
Detail:{
screen:DetailPage,
navigationOptions: {
headerTitle: '详情页',
}
},
Welcome:{
screen:WelcomePage,
//不需要导航条
navigationOptions:{
header:null
}
}
},
{
initialRouteName: "Home",
defaultNavigationOptions:{
headerStyle:{
backgroundColor:"#c20c0c",
},
//标题样式
headerTitleStyle:{
color:"#fff"
},
//返回按钮颜色
headerTintColor:"#fff"
}
},
)