【问题标题】:How to implement a createMaterialTopTabNavigator with a createBottomTabNavigator如何使用 createBottomTabNavigator 实现 createMaterialTopTabNavigator
【发布时间】:2018-08-12 12:53:17
【问题描述】:

我正在尝试在其中一个选项卡上创建 createBottomTabNavigatorcreateMaterialTopTabNavigator。它无法识别 createMaterialTopTabNavigator,它告诉我the component for route 'Home' must be a react component。我必须正确导入组件。有什么想法吗?

export const Tabs = createBottomTabNavigator(

{
    Home: AppTabs,

    'News': {
        screen: News,
        navigationOptions: {
            tabBarLabel: 'News',
            tabBarIcon: ({ tintColor }) => <Icon name="newspaper-o" type="font-awesome" size={26} color={tintColor} />,
            tabBarOptions: {
                activeTintColor: '#2896d3',
                labelStyle: {
                    fontSize: 14,
                },
            },
        },
    },
    'Garage': {
        screen: Garage,
        navigationOptions: {
            tabBarLabel: 'Garage',
            tabBarIcon: ({ tintColor }) => <Icon name="garage" type="material-community" size={34} color={tintColor} />,
            tabBarOptions: {
                activeTintColor: '#2896d3',
                labelStyle: {
                    fontSize: 14,
                },
            },
        },
    },
    'Chatbot': {
        screen: Chatbot,
        navigationOptions: {
            tabBarLabel: 'Support',
            tabBarIcon: ({ tintColor }) => <Icon name="ios-person-outline" type="ionicon" size={34} color={tintColor} />,
            tabBarOptions: {
                activeTintColor: '#2896d3',
                labelStyle: {
                    fontSize: 14,
                },
            },
        },
    },
},
{
    initialRouteName: 'News',
}
);

const AppTabs = createMaterialTopTabNavigator({
    Tab1: NewApps,
    Tab2: OtherApps,
}, {
        tabBarOptions: {
            scrollEnabled: true,
            labelStyle: {
                fontSize: 12,
            },
            tabStyle: {
                width: Dimensions.get('window').width / 2,
            },
            style: {
                backgroundColor: 'tomato',
            },
            indicatorStyle: {
                backgroundColor: '#fff'
            }
        },
    });

export const createRootNavigator = () => {
    return createStackNavigator(
        {
            Home: {
                screen: Login,
                navigationOptions: {
                    header: null,
                    gesturesEnabled: false
                }
            },
            Tabs: {
                screen: Tabs,
                navigationOptions: {
                    header: null,
                    gesturesEnabled: false
                }
            },
            ViewApp: {
                screen: ViewApp,
                navigationOptions: {
                    header: null,
                },
            },
        },
        {
            headerMode: "none",
            mode: "modal"
        }
    );
};

【问题讨论】:

    标签: react-native react-router react-navigation


    【解决方案1】:

    您在 createRootNavigator 和 createBottomTabNavigator 中都有路径名“home”,请记住路由名称不能在 Stacks 中重复。

    对不起我的英语。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-08-18
      • 2018-11-27
      • 1970-01-01
      • 1970-01-01
      • 2018-11-24
      • 1970-01-01
      • 2019-08-04
      相关资源
      最近更新 更多