微信小程序隐藏tabBar
## 原文地址
图片压缩
1、在app.json中的list内不能有非tabBar页面。简单说就是这个页面不要tabBar,那么tabBar也不要他了。
[{
"pages":\[
"pages/index/index",
"pages/logs/logs",
"pages/reg/reg"
\],
"window":{
"backgroundTextStyle":"light",
"navigationBarBackgroundColor": "#fff",
"navigationBarTitleText": "WeChat",
"navigationBarTextStyle":"black"
},
"tabBar": {
"list": \[{
"pagePath": "pages/index/index",
"text": "首页",
"iconPath": "images/home.gif",
"selectedIconPath": "images/home-HL.gif"
}, {
"pagePath": "pages/logs/logs",
"text": "日志",
"iconPath": "images/journal.gif",
"selectedIconPath": "images/journal-HL.gif"
},
// {//这些不能存在
// "pagePath": "pages/reg/reg",
// "text": "登录",
// "iconPath": "images/logo.gif",
// "selectedIconPath": "images/logo-HL.gif"
//}
\]
}
}](http://111.229.20.197/dist/index.html#/webdetail?webdetail=5e798e9499b4b11950fd5f91&type=webdetail)
如果不小心写了,在wx.navigateTo的fail回调打印错误如下:“navigateTo:fail can not navigate to tabBar page”即“不能导航到tabBar页面”。
2、在需要时使用wx.navigateTo函数。比如小程序运行时检测用户是否登录,如未登录,那么跳转到登录界面。“`
wx.navigateTo({
url:'../reg/reg'
})
微信小程序没有用来隐藏tabBar的API,完全依靠跳转来实现。其中url为必填,注意参数用法。


浙公网安备 33010602011771号