index.vue 1.4 KB
<template>
  <van-tabbar active-color="#2C66F7"
              inactive-color="#999999"
              route
              safe-area-inset-bottom>
    <van-tabbar-item v-for="(item, index) in tabList"
                     :key="index"
                     replace
                     :to="item.to">
      <span>{{ item.title }}</span>
      <template #icon="props">
        <img class="tab-icon" :src="props.active ? item.activeIcon : item.inactiveIcon" />
      </template>
    </van-tabbar-item>
  </van-tabbar>
</template>

<script>
export default {
	name: "TabBar",
	data() {
		const baseUrl = "https://img02.glsx.com.cn/weapp/resource/supervise-wecom/";
		return {
			tabList: [
				{
					title: "团队工作台",
					to: "/teamWork/teamList",
					activeIcon: baseUrl + "tab-home-active.png",
					inactiveIcon: baseUrl + "tab-home.png",
				},
				{
					title: "业绩概览",
					to: { path: "/performance/index" },
					activeIcon: baseUrl + "tab-view-active.png",
					inactiveIcon: baseUrl + "tab-view.png",
				},
				{
					title: "我的任务",
					to: "/mine/tasks",
					activeIcon: baseUrl + "tab-mine-active.png",
					inactiveIcon: baseUrl + "tab-mine.png",
				},
			],
		};
	},
};
</script>

<style lang="scss" scoped>
/* van-tabbar-item 默认图标大小比较小,我们稍微调整大一点点确保和设计图相似 */
:deep(.van-tabbar-item__icon img) {
	height: 20px;
	width: 20px;
}
</style>