Home >Web Front-end >uni-app >How to hide a bottom navigation bar in uniapp
When using uniapp to develop mobile applications, the bottom navigation bar is a very common layout method. But sometimes we need to hide the bottom navigation bar in a certain page to achieve a better user experience. This article will introduce how to hide a bottom navigation bar in uniapp.
1. Hide the bottom navigation bar
In uniapp, the bottom navigation bar is implemented through the tabbar tag. If we want to hide a certain bottom navigation bar, we can do it through the following steps:
onLoad(){ uni.hideTabBar({ index: 2 // 隐藏第三个底部导航栏(下标从0开始) }); }
onUnload(){ uni.showTabBar({ index: 2 // 显示第三个底部导航栏(下标从0开始) }); }
2. Switch the bottom navigation bar
In actual projects, we may need to switch the bottom navigation bar in scenarios such as logging in or logging out. At this time, we can achieve it through the following steps:
export default { data() { return { selectedTab: 0 // 默认选中第一个底部导航栏 } } }
export default { data() { return { isTab: true } } }
onShow(){ this.$parent.selectedTab = 1; // 选中第二个底部导航栏 }
onShow(){ if(!this.$parent.isTab){ this.$parent.hideTabBar(); } }
onUnload(){ if(!this.$parent.isTab){ this.$parent.showTabBar(); } }
Through the above steps, you can hide a bottom navigation bar or switch the bottom navigation bar in uniapp.
The above is the detailed content of How to hide a bottom navigation bar in uniapp. For more information, please follow other related articles on the PHP Chinese website!