基于Uview 自定义tabbar 不同账号显示不同的tabbar

1、在package.json中将原本的修改为

    "tabBar": {
        "list": [{
                "pagePath": "pages/home/home"
            },
            {
                "pagePath": "pages/my4/my4_performance"
            },
            {
                "pagePath": "pages/my4/my4_approve"
            },
            {
                "pagePath": "pages/my/my_new"
            }
        ]
    }

 

2.创建公共的common.js  导出两种tabbar

export const tabbar = [{
        iconPath: "/static/image/icon/tab01.png",
        selectedIconPath: "/static/image/icon/tab1.png",
        text: '首页',
        customIcon: false,
        pagePath: '/pages/home/home',
    },
    {
        iconPath: "/static/image/icon/tab02.png",
        selectedIconPath: "/static/image/icon/tab2.png",
        text: '绩效',
        customIcon: false,
        pagePath: '/pages/my4/my4_performance',
    },
    {
        iconPath: "/static/image/icon/tab03.png",
        selectedIconPath: "/static/image/icon/tab3.png",
        text: '审批',
        customIcon: false,
        pagePath: '/pages/my4/my4_approve',
    },
    {
        iconPath: "/static/image/icon/tab04.png",
        selectedIconPath: "/static/image/icon/tab4.png",
        text: '我的',
        customIcon: false,
        pagePath: '/pages/my/my_new',
    }
]

export const tabbar2 = [{
        iconPath: "/static/image/icon/tab01.png",
        selectedIconPath: "/static/image/icon/tab1.png",
        text: '首页',
        customIcon: false,
        pagePath: '/pages/home/home',
    },
    {
        iconPath: "/static/image/icon/tab04.png",
        selectedIconPath: "/static/image/icon/tab4.png",
        text: '我的',
        customIcon: false,
        pagePath: '/pages/my/my_new',
    }
]

3.在页面中导入

import { tabbar, tabbar2} from "../../common/common.js"

在data中定义:

list: tabbar,
list2: tabbar2,

current: 0,        //当前的索引
inactiveColor: '#7A7E83',    //未选中颜色
activeColor: '#fd9928',        //选中颜色

4.每个需要的页面中添加组件

//根据iscustomer,判断显示哪种tabbar

<u-tabbar v-model="current"  :list="iscustomer?list2:list" :inactive-color="inactiveColor"
  :activeColor="activeColor">
</u-tabbar>

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值