javascript - 如何隐藏特定屏幕上的底部标签栏(react-navigation 3.x)
问题描述
我使用了 createBottomTabNavigator,但我无法在特定屏幕上隐藏底部应用栏
const StackHome = createStackNavigator(
{
Home: Home,
Autor: Autor,
Publicacion: Publicacion,
Comentarios: {
screen: Comentarios,
navigationOptions:{
// this should do the work, but it doesn't
tabBarVisible: false
}
}
}
);
解决方案
最后我得到了一个可行的解决方案,组件是这样的
import { createStackNavigator } from "react-navigation";
import Home from "./Home";
import Autor from "./Profile";
import Publicacion from "./Publicacion";
import Comentarios from "./Comentarios";
const StackHome = createStackNavigator({
Home: Home,
Autor: Autor,
Publicacion: Publicacion,
Comentarios: Comentarios
});
// This does the trick
StackHome.navigationOptions = ({ navigation }) => {
let tabBarVisible;
if (navigation.state.routes.length > 1) {
navigation.state.routes.map(route => {
if (route.routeName === "Comentarios") {
tabBarVisible = false;
} else {
tabBarVisible = true;
}
});
}
return {
tabBarVisible
};
};
export default StackHome;
推荐阅读
- sql - 获取特定日期范围内特定用户的未结案件数
- python - ValueError:字段“IFORM”出现多次
- algorithm - 分配最大可用内存
- javascript - 无法更新 setInterval 内的变量值
- assembly - 在汇编 x86 中使用 INVOKE 和 PROTO
- powerbi - 无法在 Power BI 中使用导入的 topoJson 文件进行自定义地图可视化
- django-viewflow - django-viewflow 如何使用 SubProcess
- r - 在 Shiny Dashboard 中使选项卡具有交互性
- jboss - 域模式下主从服务器组启动中JBoss执行的活动列表
- assembly - 汇编 32 位寻址大小而不是 64 位模式下的 64 位