在React Native Navigation V2中添加选项卡导航

问题描述 投票:2回答:1

我正在尝试在我的React Native App中使用导航。我已经安装了V2。以下设置不显示任何选项卡。

Navigation.events().registerAppLaunchedListener(()=>{
Navigation.setRoot({
root: {
  topTabs: {
    children:[{
      stack: {
        children: [
          {
            component: {
              name: 'news.MainScreen',
              text: 'tab1',
              passProps: {
                text: 'This is tab 1'
              },
              options: {
                topTab: {
                  text: "tab 1",
                  testID: 'NO_IDEA'
                }
              }

            },
          },
          {
            component: {
              name: 'news.SplashScreen',
              text: 'tab2',
              passProps: {
                text: 'This is tab 6'
              }
            },
            options: {
              topTab: {
                text: "tab 21",
                testID: 'NO_IDEA_1'
              }
            }
          },
        ]
      }
    }],
   }
 }
})

});

当我编译我的应用程序时,这是结果:

result of the code above

欢迎所有建议。

javascript reactjs react-native navigation react-native-navigation
1个回答
1
投票

看起来你只有一个孩子。只尝试第一个标签(在水龙头中没有堆叠)

Navigation.setRoot({
      root: {
                topTabs: {
                children: [
                  {
                    component: {
                      name: "screens.tab1",
                      options: {
                        topTab: {
                          title: "Tab 1"
                        }
                      }
                    }
                  },
                  {
                    component: {
                      name: "screens.tab2",
                      options: {
                        topTab: {
                          title: "Tab 2"
                        }
                      }
                    }
                  },
                  {
                    component: {
                      name: "screens.tab3",
                      options: {
                        topTab: {
                          title: "Tab 3"
                        }
                      }
                    }
                  }
                ]
              }
      }
    });
© www.soinside.com 2019 - 2024. All rights reserved.