我正在使用“ createMaterialTopTabNavigator for” 标签在我的应用中起作用。 它工作正常,可以成功导航到initialRouteName或默认屏幕(标签导航器中的第一个屏幕)。
我的routes.js
const StackNavigator = defaultRoute =>
createStackNavigator(
{
Auth: {
screen: Auth
},
Home: {
screen: Home
},
ClubDashboard: {
screen: ClubDashboard
},
MemberHome: {
screen: MemberHomeTabNavigator
},
ClubHome: {
screen: ClubHomeTabNavigator
},
Profile: {
screen: Profile
},
MemberContributions: {
screen: MemberContributions
},
MemberLoans: {
screen: MemberLoans
},
ClubContributions: {
screen: ClubContributions
},
ClubLoans: {
screen: ClubLoans
},
ClubExpenses: {
screen: ClubExpenses
}
},
{
initialRouteName: defaultRoute
}
);
const MemberHomeTabNavigator = createMaterialTopTabNavigator(
{
Contributions: {
screen: MemberContributions
},
Loans: {
screen: MemberLoans
},
Profile: {
screen: Profile
}
},
{
tabBarOptions: {
activeTintColor: GLOBAL_CONFIG.COLOR.THEME,
inactiveTintColor: GLOBAL_CONFIG.COLOR.BLACK,
labelStyle: {
fontSize: 11
},
style: {
backgroundColor: GLOBAL_CONFIG.COLOR.WHITE
},
indicatorStyle: {
backgroundColor: GLOBAL_CONFIG.COLOR.BLACK
}
},
},
);
我正在 this.props.navigation.push('MemberHome')导航到“标签”屏幕。
在我的代码中有多个对“ this.props.navigation.push('MemberHome')”的调用(一个用于借贷,一个用于贡献,一个用于配置文件)
我想要的是:
当我单击访问“贷款”时,->“选项卡”中的“贷款”屏幕应处于活动状态或initialRoute
当我单击以访问“贡献”时,“标签”中的->“贡献”屏幕应处于活动状态或initialRoute
当我单击访问配置文件时,选项卡中的->配置文件屏幕应该处于活动状态或initialRoute
如何在createMaterialTopTabNavigator中动态更改InitialRouteName / Tab屏幕?