【问题标题】:react native expo how to make nested tab反应原生博览会如何制作嵌套标签
【发布时间】:2019-04-28 09:19:19
【问题描述】:

我正在使用 react-navigation 制作底部标签。现在我想在底部导航之一中添加爱好和工作选项卡。像照片中的东西。

你如何做这样的嵌套选项卡添加jobby和job选项卡并使其工作?

这个当前的 mainTabnavigator.js

const HomeStack = createStackNavigator({
  Home: HomeScreen,
});

HomeStack.navigationOptions = {
  tabBarLabel: 'Home',
};

const LinksStack = createStackNavigator({
  Links: LinksScreen,
});

LinksStack.navigationOptions = {
  tabBarLabel: 'Links',

};

const SettingsStack = createStackNavigator({
  Settings: SettingsScreen,
});

SettingsStack.navigationOptions = {
  tabBarLabel: 'Settings',
};

export default createBottomTabNavigator({
  HomeStack,
  LinksStack,
  SettingsStack,
});

还有 AppNavigator.js

import React from 'react';
import { createAppContainer, createSwitchNavigator } from 'react-navigation';

import MainTabNavigator from './MainTabNavigator';

export default createAppContainer(createSwitchNavigator({
  // You could add another route here for authentication.
  // Read more at https://reactnavigation.org/docs/en/auth-flow.html
  Main: MainTabNavigator,
}));

App.js

export default class App extends React.Component {
  state = {
    isLoadingComplete: false,
  };

  render() {
    if (!this.state.isLoadingComplete && !this.props.skipLoadingScreen) {
      return (
        <AppLoading
          startAsync={this._loadResourcesAsync}
          onError={this._handleLoadingError}
          onFinish={this._handleFinishLoading}
        />
      );
    } else {
      return (
        <View style={styles.container}>
          {Platform.OS === 'ios' && <StatusBar barStyle="default" />}
          <AppNavigator />
        </View>
      );
    }
  }
}

linkScreen.js

<ScrollView style={styles.container} contentContainerStyle={styles.con}>
                <View style={styles.box}>
                    <View style={styles.tab}>
                        <Text onPress={this.gotoHobby}>Hobby</Text>
                    </View>
                    <View style={styles.tab}>
                        <Text onPress={this.gotoJob}>Job</Text>
                    </View>
                </View>
            </ScrollView>

【问题讨论】:

    标签: react-native expo


    【解决方案1】:

    你可以使用'native-base'的tabs函数。

    example.js

    import React, { Component } from 'react';
    import { Container, Content, Tabs } from 'native-base';
    
    import TabOne from './tabOne';
    import TabTwo from './tabTwo';
    ​
    export default class ThemeTabsExample extends Component {
        render() {
            return (
                <Container>
                    <Content>
                        <Tabs>
                            <TabOne tabLabel='One' />
                            <TabTwo tabLabel='Two' />
                        </Tabs>
                    </Content>
                </Container>
            );
        }
    }
    

    这是detail link 关于native-base Tabs

    【讨论】:

    • 不推荐native-base,已经使用选项卡好几个月了,这不过是一场噩梦......最新版本甚至没有文档。使用和定制确实是一件令人头疼的事情。正在寻找替代品。
    • @JoshMartin 当您提出问题时,如果您以我的方式解决了问题,请检查我的答案中的 V 标记,投票,结束问题,然后创建一个新问题。
    猜你喜欢
    • 1970-01-01
    • 2023-03-11
    • 2019-01-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-10-23
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多