微信小程序自定义tabBar根据不同角色展示不同菜单
- "custom": true ,在app.json中,tabBar中开启自定义;
- 微信官方文档的自定义 tabBar
传送门:https://developers.weixin.qq.com/miniprogram/dev/framework/ability/custom-tabbar.html
项目根目录下建立相同文件夹
- 设置index.js文件(“custom-tab-bar”中的index.js)
Component({
data: {
selected: 0,
color: "#000000",
roleId: '',
selectedColor: "#1396DB",
allList: [{
list1: [{
pagePath: "/pages/user/user",
text: "技术",
iconPath: "/images/user-white.png",
selectedIconPath: "/images/user-white.png"
},
{
pagePath: "/pages/order/orders",
text: "订单",
iconPath: "/images/order0-white.png",
selectedIconPath: "/images/order0-white.png"
},
{
pagePath: "/pages/home/home",
text: "主页",
iconPath: "/images/home-white.png",
selectedIconPath: "/images/home-white.png"