如果运行以下代码,则抽屉导航的标题不会被设置样式。谁知道为什么?这是我之前的问题的简化示例,其中我有其他嵌套导航器。这个例子只是两个抽屉 - 将navigationOptions添加到类中似乎也不起作用。
import React from 'react';
import { createDrawerNavigator } from 'react-navigation';
import { Text, View } from 'react-native';
class Drawer1 extends React.Component {
render() {
return (
<View>
<Text>Drawer 1</Text>
</View>
);
}
}
class Drawer2 extends React.Component {
render() {
return (
<View>
<Text>Drawer 2</Text>
</View>
);
}
}
const DrawerNavigator = createDrawerNavigator(
{
Drawer1: {
screen: Drawer1,
navigationOptions: {
drawerLabel: 'Drawer1',
}
},
Drawer2: {
screen: Drawer2,
navigationOptions: {
drawerLabel: 'Drawer2',
}
},
},
{
initialRouteName: 'Drawer1',
drawerPosition: 'right',
navigationOptions: {
headerStyle: {
backgroundColor: '#9f4c87',
},
headerTintColor: '#fff',
headerTitleStyle: {
fontWeight: 'bold',
},
},
}
);
export default class App extends React.Component {
render() {
return (
<DrawerNavigator />
);
}
}