TabBar.vue
1.56 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
<template>
<van-tabbar
route
@change="change"
v-model="value"
:border="false"
:safe-area-inset-bottom="true"
>
<template v-for="(i,index) in data">
<van-tabbar-item
:key="index"
replace
:to="`/${i.name}`"
:name="i.name"
>
{{i.title}}
<template #icon="props">
<img :src="props.active ? i.active : i.inactive" />
</template>
<div
class="line y-center"
v-if="index < data.length - 1"
></div>
</van-tabbar-item>
</template>
</van-tabbar>
</template>
<script>
export default {
name: 'TabBar',
props: {
routerName: {
type: String,
default: 'home'
},
parent: String,
data: {
type: Array,
default: () => {
return []
}
}
},
data () {
return {
value: this.routerName
}
},
methods: {
change (value) {
this.$emit('change', value)
}
}
}
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped lang='scss'>
.van-tabbar {
background: linear-gradient(180deg, #ffffff 0%, #ffffff 100%);
box-shadow: 0px -2px 4px 0px rgba(0, 0, 0, 0.04);
border-radius: 10px 10px 0px 0px;
overflow: hidden;
z-index: 3;
.van-tabbar-item--active {
color: var(--themeColor);
}
.van-tabbar-item {
font-size: 16px;
position: relative;
.line {
width: 1px;
height: 34px;
background: #e9e9e9;
right: 0;
}
}
.van-tabbar-item__icon img {
width: 20px;
height: 20px;
}
}
</style>