在app.json处设置“tabBar”,例子如下:
{ "pages": [ "pages/index/index", "pages/pages1/pages1", "pages/pages2/pages2" ], "window": { "backgroundTextStyle": "light", "navigationBarBackgroundColor": "#ffffff", "navigationBarTitleText": "小程序名称", "navigationBarTextStyle": "black", "backgroundColor": "#EA0000" }, "sitemapLocation": "sitemap.json", "tabBar": { "color": "#666666", "selectedColor": "#f10b2e", "list": [ { "pagePath": "pages/pages1/pages1", "text": "页面1", "iconPath": "*****",//未选中时的图标 "selectedIconPath": "*****"//选中后的图标 }, { "pagePath": "pages/pages2/pages2", "text": "页面2", "iconPath": "*****",//未选中时的图标 "selectedIconPath": "*****"//选中后的图标 } ] } }
需要注意的是:其他页面要跳转到tabBar页面,需要使用wx.switchTab,例子如下:
wx.switchTab({ url: ‘../pages1/pages1‘ })