React Navigation - 创建tab导航器元素不起作用?

时间:2018-05-26 21:22:50

标签: css reactjs react-native react-native-android react-navigation

我正在尝试使用React Navigation创建标签式布局。这是我的代码:

const Navigator = createMaterialTopTabNavigator({
    Wines,
    Stores,
    Vineyards,
    Restaurants
});

// in render()
<View style={styles.navContainer}>
    <Navigator
        screenProps={this.getScreenProps()}
    />
    <Text>Hello, world!</Text> // Put here for demonstrational purposes
</View>

这就是结果:

基本上导航仪没有占用任何空间,我不知道为什么。我也试过这个

const Navigator = createMaterialTopTabNavigator({
    Wines: {screen: Wines},
    Stores: {screen: Stores},
    Vineyards: {screen: Vineyards},
    Restaurants: {screen: Restaurants}
});

Navigator JSX传入style={{width: 200, height: 200}},但似乎没有做任何事情。我做错了什么?

1 个答案:

答案 0 :(得分:0)

您必须确保在您使用的每个NODE *中指定flexDirectionheight样式属性。我将View添加到height内的父视图中,它运行正常。

链接:https://snack.expo.io/Hy-oLAvJ7

相关问题