tabBar.vue
2.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<template>
<div class="tabbar">
<van-tabbar v-model="tabbarTempValue" @change="onChange" active-color="#599158">
<van-tabbar-item>
课堂
<template #icon="props">
<img class="icon-img ketangimg" :src="props.active ? icon.courseactive : icon.course" />
</template>
</van-tabbar-item>
<van-tabbar-item>
社区
<template #icon="props">
<img class="icon-img shequimg" :src="props.active ? icon.shequactive : icon.shequ" />
</template>
</van-tabbar-item>
<van-tabbar-item>
活动中心
<template #icon="props">
<img
class="icon-img activityimgk"
:src="props.active ? icon.societyactive : icon.society"
/>
</template>
</van-tabbar-item>
<van-tabbar-item>
个人中心
<template #icon="props">
<img class="icon-img centerimg" :src="props.active ? icon.personactive : icon.person" />
</template>
</van-tabbar-item>
</van-tabbar>
</div>
</template>
<script>
import Vue from "vue";
import { Tabbar, TabbarItem } from "vant";
import { Icon } from "vant";
import { Notify } from "vant";
Vue.use(Notify);
Vue.use(Tabbar).use(TabbarItem);
Vue.use(Icon);
export default {
props: {
active: Number
},
data() {
return {
tabbarTempValue: this.active,
icon: {
course: require("../../assets/ketang.png"),
courseactive: require("../../assets/ketangactive.png"),
shequ: require("../../assets/shequ.png"),
shequactive: require("../../assets/shequactive.png"),
society: require("../../assets/society.png"),
societyactive: require("../../assets/societyactive.png"),
person: require("../../assets/person.png"),
personactive: require("../../assets/personactive.png")
}
};
},
methods: {
onChange(index) {
const routerArray = ["/", "/society", "/activity", "/usercenter"];
this.$router.push(routerArray[index]);
}
}
};
</script>
<style>
/* .van-tabbar-item__icon img {
width: 0.54rem;
height: 0.44rem;
} */
.ketangimg {
width: 0.44rem;
height: 0.38rem !important;
}
.shequimg {
width: 0.44rem;
height: 0.38rem !important;
}
.activityimgk {
width: 0.45rem;
height: 0.38rem !important;
}
.centerimg {
width: 0.45rem;
height: 0.38rem !important;
}
</style>