首页 > 解决方案 > Stacknavigator 中 Tabnavigator 的导航

问题描述

我正在开发一个 react native 项目,我同时使用 Stack navigator 和 Tab navigator。应用程序的主要流程应该在堆栈导航中。我在其中一个屏幕上添加了一个按钮,该按钮在标签导航中,但导航没有发生!我怎样才能得到帮助,请帮助我示例代码:

  const Nav=createStackNavigator({
    Splash: Splash,
    Login: Login,
    Tab:tab
  })

  const Tab=createBottomNavigator({
    Home:Home,
    Profile:Profile // i added button in this screen want to navigate to Login
})

标签: react-nativereact-navigation

解决方案


我可以通过为我想要在标签导航中的屏幕创建另一个堆栈来解决导航问题,如下所示并且能够实现导航。

//New Stack
 const Stack=createStackNavigator({
  Profile:Profile,
  Login:Login
    })
 //Old Stacks         
   const Tab=createBottomTabNavigator({
     Home:Home,
       Profile:Profile
   })
    const Nav=createStackNavigator({
      Splash:Splash,
      Login:Login,
      Tab:Tab
})

推荐阅读