在视图中嵌套堆栈导航器

时间:2018-12-27 15:21:33

标签: javascript react-native

我已经实现了堆栈导航,但是一无所知。如果我以视图样式删除{flex:1},为什么它不显示菜单组件?

import React, { Component } from 'react';
import Menu from './MenuComponent';
import { View, Platform} from 'react-native';
import { DISHES } from '../shared/dishes';
import Dishdetail from './DishdetailComponent';
import { createStackNavigator } from 'react-navigation';

const MenuNavigator = createStackNavigator({
    Menu: { screen: Menu },
    Dishdetail: { screen: Dishdetail }
},
{
    initialRouteName: 'Menu',
    navigationOptions: {
        headerStyle: {
            backgroundColor: "#512DA8"
        },
        headerTintColor: '#fff',
        headerTitleStyle: {
            color: "#fff"            
        }
    }
}
);
class Main extends Component {
    
    render() {
        return (
            <View style={{flex:1, paddingTop: Platform.OS === 'ios' ? 0 : Expo.Constants.statusBarHeight }}>
                <MenuNavigator />
            </View>
        );
    }
}
export default Main;

0 个答案:

没有答案