带选项卡的BottomTabs

时间:2018-08-22 07:12:31

标签: react-native react-native-navigation

我将React Native导航v2用于导航,并且尝试使用底部标签和侧面菜单进行布局。这是我目前的布局

export const goHome = () => Navigation.setRoot({
  root: {
    sideMenu: {
      left: {
        component: {
          name: 'app.SideMenu',
        },
      },
      center: {
          bottomTabs: {
            id: 'BottomTabsId',
            options: {
              topbar: {
                visible: true,
              }
            },
            children: [
              {
                component: {
                  name: SERVICES_SCREEN.id,
                  options: {
                    topBar: {
                      title: {
                        text: "Tab One"
                      },
                    },
                    bottomTab: {
                      badge: '2',
                      fontSize: 12,
                      text: 'Create Job',
                      icon: require('./res/beep-green.png')
                    }
                  }
                },
              },
              {
                component: {
                  name: CREDITS_SCREEN.id,
                  options: {
                    topBar: {
                      title: {
                        text: "Tab One"
                      },
                    },
                    bottomTab: {
                      badge: 'New',
                      text: 'Credits',
                      fontSize: 12,
                      icon: require('./res/beep-green.png')
                    }
                  }
                },
              },
              {
                component: {
                  name: PROFILE_SCREEN.id,
                  options: {
                    topBar: {
                      title: {
                        text: "Tab One"
                      },
                    },
                    bottomTab: {
                      badge: '',
                      text: 'Profile',
                      fontSize: 12,
                      icon: require('./res/beep-green.png')
                    }
                  }
                },
              },
            ],
          },
      }
    }
  }
});

问题是我希望标签页也具有标签栏,我该如何实现?

1 个答案:

答案 0 :(得分:0)

使用此布局解决了

export const goHome = () => Navigation.setRoot({
  root: {
    sideMenu: {
      left: {
        component: {
          name: 'app.SideMenu',
        },
      },
      center: {
        bottomTabs: {
          id: 'BottomTabsId',
          options: {
            topbar: {
              visible: true,
            }
          },
          children: [
            {
              stack: {
                id: 'Tabs',
                children: [
                  {
                    component: {
                      name: SERVICES_SCREEN.id,
                      options: {
                        topbar: {
                          visible: true
                        },
                        bottomTab: {
                          badge: '2',
                          fontSize: 12,
                          text: 'Create Job',
                        }
                      }
                    },
                  },
                ]
              }
            },
            {
              stack: {
                id: 'Tabs2',
                children: [
                  {
                    component: {
                      name: CREDITS_SCREEN.id,
                      options: {
                        bottomTab: {
                          badge: 'New',
                          text: 'Credits',
                          fontSize: 12,
                        }
                      }
                    },
                  },
                ]
              }
            },
            {
              stack: {
                id: 'Tabs3',
                children: [
                  {
                    component: {
                      name: PROFILE_SCREEN.id,
                      options: {
                        bottomTab: {
                          badge: '',
                          text: 'Profile',
                          fontSize: 12,
                        }
                      }
                    },
                  },
                ]
              }
            },
          ],
        },
      }
    }
  }
});