React Native App中的React Navigation - navigationOptions样式不适用于drawerNavigator

时间:2018-06-07 09:09:26

标签: react-native react-navigation

如果运行以下代码,则抽屉导航的标题不会被设置样式。谁知道为什么?这是我之前的问题的简化示例,其中我有其他嵌套导航器。这个例子只是两个抽屉 - 将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 />
    );
  }
}

0 个答案:

没有答案