React native 使用bottomtabnavigator时,stacknavigator的屏幕导航不起作用
我是新来的本地人,在屏幕之间导航时遇到了问题。 我使用的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
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}}
)}