设计了登录页后,想跳转到首页内容页面,但是只希望有限页面在tabBar中。
首先需要在app.json中设置程序一开始进入的页面为登录页,并且设置好tabBar:
"entryPagePath": "pages/login/login",
"pages": [
"pages/home/home",
"pages/login/login",
"pages/equipmentQuery/equipmentQuery",
"pages/index/index",
"pages/workbench/workbench",
"pages/serv/serv",
"pages/ddj/ddj",
"pages/subscribe/subscribe"
],
"tabBar": {
"selectedColor": "#f3514f",
"color": "#666",
"backgroundColor": "#efefef",
"list": [
{
"text": "工作台",
"pagePath": "pages/workbench/workbench",
"iconPath": "/assets/bar1.png",
"selectedIconPath": "/assets/bar1.png"
},
{
"text": "打地基",
"pagePath": "pages/ddj/ddj",
"iconPath": "/assets/bar2.png",
"selectedIconPath": "/assets/bar2.png"
},
{
"text": "服务",
"pagePath": "pages/serv/serv",
"iconPath": "/assets/bar3.png",
"selectedIconPath": "/assets/bar3.png"
},
{
"text": "我",
"pagePath": "pages/home/home",
"iconPath": "/assets/tel.png",
"selectedIconPath": "/assets/tel.png"
}
]
},
然后就是在登录页点击登录按钮进行跳转的时候,需要使用wx.switchTab进行页面跳转:
login(){
wx.switchTab({
url: '../home/home'
});
},
这样子就可以跳转到正确的首页,并且首页下面的tabBar是自己定义的那几个页面内容:
需要注意的是,如果需要跳转的页面是tabBar里的内容,都需要使用wx.switchTab进行跳转