Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/templates/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
React native 使用bottomtabnavigator时,stacknavigator的屏幕导航不起作用_React Native_React Navigation_Stack Navigator - Fatal编程技术网

React native 使用bottomtabnavigator时,stacknavigator的屏幕导航不起作用

React native 使用bottomtabnavigator时,stacknavigator的屏幕导航不起作用,react-native,react-navigation,stack-navigator,React Native,React Navigation,Stack Navigator,我是新来的本地人,在屏幕之间导航时遇到了问题。 我使用的stacknavigator如下所示: const RootStack = createStackNavigator( { Splash: { screen: SplashScreen}, Mobile:{screen:MobileAuthentication} , Code:{screen:CodeAuthentication} , Home: { screen: H

我是新来的本地人,在屏幕之间导航时遇到了问题。 我使用的stacknavigator如下所示:

const RootStack = createStackNavigator(
    {
        Splash: { screen: SplashScreen},
        Mobile:{screen:MobileAuthentication} ,
        Code:{screen:CodeAuthentication} ,
        Home: { screen: HomeScreen },
        ProfileScreen: { screen: ProfileScreen },
        ProfileDetails: { screen: ProfileDetails },
    },
    { initialRouteName: 'Splash'}
);
const AppContainer = createAppContainer(RootStack);
在我的主屏幕中,我使用buttomtabnavigator

const bottomTabNavigator = createBottomTabNavigator(
  {
    A: {
      screen: ProfileScreen,
      navigationOptions: {
...
      }
    },
    B: {
      screen: FilterScreen,
      navigationOptions: {
...
      }
    },
  },
  {
    initialRouteName: 'FilterScreen',
    tabBarOptions: {
      activeTintColor: '#3F51B5'
    }
  }
);
const AppContainer = createAppContainer(bottomTabNavigator);
问题是,当我想通过
onpress
ProfileScreen
导航到
ProfileDetails
时,它就不起作用了

       <ProfileBtn
          onPress={() => {
            console.log('item Clicked'),
            this.props.navigation.navigate('ProfileDetails')
          } }
         />
{
console.log('item Clicked'),
this.props.navigation.navigate('ProfileDetails'))
} }
/>

愿此博客对您有所帮助。

也许您应该尝试将“导航”传递到stackNavigator创建中,使用smthg的选项,如下所示(对于每个堆栈屏幕或至少对于您希望使用它的堆栈屏幕):


如果这不是答案,请向我们提供您在控制台中遇到的错误。

谢谢。我通过访问屏幕上的道具解决了问题
options={({route, navigation}) => (
                {headerTitle: 'Splash',
                route: {route}, 
                navigation: {navigation}}
            )}