React native 反应导航:是否可以从不同的堆栈导航器导航到同一屏幕?
我正在编写一个使用react导航的应用程序。我的应用程序有一个底部TabNavigator,其中每个选项卡都包含一个stackNavigator,如下所示: Routes.js:React native 反应导航:是否可以从不同的堆栈导航器导航到同一屏幕?,react-native,react-navigation,react-navigation-stack,React Native,React Navigation,React Navigation Stack,我正在编写一个使用react导航的应用程序。我的应用程序有一个底部TabNavigator,其中每个选项卡都包含一个stackNavigator,如下所示: Routes.js: const FirstStack = createStackNavigator({ First: { screen: FirstScreen, navigationOptions: { header: props => <AppToolbar
const FirstStack = createStackNavigator({
First: {
screen: FirstScreen,
navigationOptions: {
header: props => <AppToolbar />
}
}
});
const SecondStack = createStackNavigator({
Second: {
screen: SecondScreen,
navigationOptions: {
header: props => <AppToolbar />
}
}
});
const ThirdStack = createStackNavigator({
Third: {
screen: ThirdScreen,
navigationOptions: {
header: props => <AppToolbar />
}
}
});
const FourthStack = createStackNavigator({
Fourth: {
screen: FourthScreen,
navigationOptions: {
header: props => <AppToolbar />
}
}
});
const FifthStack = createStackNavigator({
Fifth: {
screen: FifthScreen,
navigationOptions: {
header: props => <AppToolbar />
}
}
});
export const AppStack = createBottomTabNavigator(
{
First: {
screen: FirstStack,
navigationOptions: {
title: "First",
tabBarLabel: "First",
tabBarIcon: ({ tintColor }) => (
<Icon name="ios-home" color={tintColor} size={24} />
)
}
},
Second: {
screen: SecondStack,
navigationOptions: {
title: "Second",
tabBarLabel: "Second",
tabBarIcon: ({ tintColor }) => (
<Icon name="ios-clock" color={tintColor} size={24} />
)
}
},
Third: {
screen: ThirdStack,
navigationOptions: {
title: "Third",
tabBarLabel: "Third",
tabBarIcon: ({ tintColor }) => (
<Icon name="ios-fitness" color={tintColor} size={24} />
)
}
},
Fourth: {
screen: FourthStack,
navigationOptions: {
title: "Fourth",
tabBarLabel: "Fourth",
tabBarIcon: ({ tintColor }) => (
<Icon
name="ios-cloud-download"
color={tintColor}
size={24}
/>
)
}
},
Fifth: {
screen: FifthStack,
navigationOptions: {
title: "Fifth",
tabBarLabel: "Fifth",
tabBarIcon: ({ tintColor }) => (
<Icon name="ios-person" color={tintColor} size={24} />
)
}
}
},
{
initialRouteName: "First",
order: ["First", "Second", "Third", "Fourth", "Fifth"],
tabBarOptions: {
activeTintColor: "white",
inactiveTintColor: "grey",
style: {
backgroundColor: "#121212",
borderTopColor: "#303030"
}
}
}
);
const FirstStack=createStackNavigator({
第一:{
屏幕:第一屏幕,
导航选项:{
标题:道具=>
}
}
});
const SecondStack=createStackNavigator({
第二:{
屏幕:第二屏幕,
导航选项:{
标题:道具=>
}
}
});
const ThirdStack=createStackNavigator({
第三:{
屏幕:第三屏幕,
导航选项:{
标题:道具=>
}
}
});
const FourthStack=createStackNavigator({
第四:{
屏幕:第四屏幕,
导航选项:{
标题:道具=>
}
}
});
const FifthStack=createStackNavigator({
第五:{
屏幕:第五屏幕,
导航选项:{
标题:道具=>
}
}
});
export const AppStack=createBottomTabNavigator(
{
第一:{
屏幕:FirstStack,
导航选项:{
标题:“第一”,
tabBarLabel:“第一”,
tabBarIcon:({tintColor})=>(
)
}
},
第二:{
屏幕:第二堆栈,
导航选项:{
标题:"第二",
tabBarLabel:“第二个”,
tabBarIcon:({tintColor})=>(
)
}
},
第三:{
屏幕:第三台,
导航选项:{
标题:“第三次”,
tabBarLabel:“第三”,
tabBarIcon:({tintColor})=>(
)
}
},
第四:{
屏幕:第四层,
导航选项:{
标题:“第四”,
tabBarLabel:“第四”,
tabBarIcon:({tintColor})=>(
)
}
},
第五:{
屏幕:第五堆栈,
导航选项:{
标题:“第五”,
tabBarLabel:“第五”,
tabBarIcon:({tintColor})=>(
)
}
}
},
{
initialRouteName:“第一”,
顺序:[“第一”、“第二”、“第三”、“第四”、“第五”],
选项卡选项:{
activeTintColor:“白色”,
颜色:“灰色”,
风格:{
背景颜色:“121212”,
边框颜色:“303030”
}
}
}
);
tabNavigator中选项卡内的每个stackNavigator都有自己的标题,因此我可以自定义每个选项卡的标题,但所有标题都有一个按钮,该按钮应导航到配置文件屏幕(在本例中为联系人图标)
AppToolbar.js:
const appToolbar = props => {
return (
<View style={styles.toolbar}>
<Text style={styles.toolbarTitle}>Title</Text>
<TouchableOpacity onPress={...}>
<Icon
name="ios-contact"
color="grey"
size={30}
style={{ padding: 0, margin: 0, marginRight: 10 }}
/>
</TouchableOpacity>
</View>
);
};
const-appToolbar=props=>{
返回(
标题
);
};
我想做的是,通过按下联系人图标,应用程序应该导航到配置文件屏幕,我不知道的是,是否可以定义从任何地方都可以访问的全局路由,或者我必须将配置文件屏幕添加到所有StackNavigator,以便从每个堆栈中的每个屏幕都可以访问它
提前谢谢 在这里找到了答案
使用stackNavigator,将概要文件堆栈和tabNavigator作为子级,使tabNavigator成为默认路径。I添加“到所有stackNavigator”