我使用从“ react-navigation-tabs”导入的底部标签导航器
import { createBottomTabNavigator } from 'react-navigation-tabs';
const AppNavigator = createBottomTabNavigator({
Homepage: {
screen: Screen1
},
Screen2: {
screen: Screen2
}
} , {
initialRouteName:"Screen1"
});
屏幕1是堆栈导航器
const AppNavigator = createStackNavigator({
Homepage: {
screen: Screen1,
},
Screen2: {
screen: Screen2
}
} , {
initialRouteName : "Homepage",
headerMode:"none",
navigationOptions: ({ navigation }) => ({
tabBarVisible: navigation.state.routes[navigation.state.index].routeName === 'Screen2' ? false : true
})
});
经过研究,我发现了以下解决方案,但没有用
navigationOptions: ({ navigation }) => ({
tabBarVisible: navigation.state.routes[navigation.state.index].routeName === 'Screen2' ? false : true
})
这是一个坏消息,因为即使将其隐藏在所有屏幕上,下面的代码也无法正常工作
navigationOptions: ({ navigation }) => ({
tabBarVisible: false
})
经过大量研究并尝试了数十种解决方案后,这些标签始终可见
答案 0 :(得分:0)
尝试一下:
Screen1.navigationOptions = ({ navigation }) => {
let tabBarVisible = true;
let routeName = navigation.state.routes[navigation.state.index].routeName
if ( routeName == 'ScreenX' ) {
tabBarVisible = false
}
return {
tabBarVisible,
}
}