Roc*_*cco 1 javascript react-native react-navigation
我使用了 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
}
}
}
);
Run Code Online (Sandbox Code Playgroud)
Roc*_*cco 11
最后我得到了一个有效的解决方案,组件将是这样的
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;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8502 次 |
| 最近记录: |