uniapp隐藏指定底部tabbar
时间: 2023-10-03 09:10:05 浏览: 81
要隐藏指定底部的tabbar,可以在页面的onShow()方法中使用uni.hideTabBar()函数。具体的做法是,在pages.json文件中的tabbar字段里添加需要隐藏的tab项,然后在相应的页面中的onShow()方法中调用uni.hideTabBar()函数即可。
以下是一个示例的代码:
pages.json文件中的tabbar字段:
```
"tabbar": {
"color": "#000",
"selectedColor": "#07c160",
"backgroundColor": "#fff",
"list": [
{
"pagePath": "pages/home/index",
"text": "首页",
"iconPath": "static/images/tab_home.png",
"selectedIconPath": "static/images/tab_home_sel.png"
},
{
"pagePath": "pages/recommend/index",
"text": "推荐",
"iconPath": "static/images/tab_recommend.png",
"selectedIconPath": "static/images/tab_recommend_sel.png",
"isHide": true // 需要隐藏的tab项
},
{
"pagePath": "pages/my/index", "text": "我的",
"iconPath": "static/images/tab_my.png",
"selectedIconPath": "static/images/tab_my_sel.png"
}
]
}
```
页面中的onShow()方法:
```javascript
onShow() {
uni.hideTabBar({
index: 1 // 需要隐藏的tab项的索引,根据实际情况调整
});
}
```