index.vue
2.5 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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<template>
<div class="container">
<div class="content">
<transition>
<keep-alive>
<router-view></router-view>
</keep-alive>
</transition>
</div>
<div class="list display-flex-around">
<router-link
:to="item.link"
class="link display-flex"
v-for="(item,index) in tabs"
:key="index"
active-class="active"
@click.native="chooseNav(index)"
>
<img :src="current==index?item.selectimage:item.image" alt="" />
<span >{{item.test}}</span>
</router-link>
</div>
</div>
</template>
<script>
export default {
data () {
return {
current: 0,
tabs: [
{
image: require('../../assets/img/homeer.png'),
selectimage: require('../../assets/img/home.png'),
test: '首页',
link: '/home'
},
{
image: require('../../assets/img/test0.png'),
selectimage: require('../../assets/img/test.png'),
test: '全能题库',
link: '/test'
},
{
image: require('../../assets/img/my0.png'),
selectimage: require('../../assets/img/my.png'),
test: '我的',
link: '/my'
}
]
}
},
methods: {
chooseNav (e) {
this.current = e
}
},
activated (e) {
// console.log(e)
},
created () {
const that = this
const path = this.$router.history.current.path
that.tabs.forEach((item, index) => {
// eslint-disable-next-line eqeqeq
if (path == item.link) {
that.current = index
}
})
// console.log(localStorage.getItem('indexCurrent'))
// this.current = localStorage.getItem('indexCurrent') ? localStorage.getItem('indexCurrent') : '0'
}
}
</script>
<style scoped lang="scss">
.container{
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
}
.list {
position: fixed;
background: #fff;
bottom: 0;
left: 0;
z-index: 99;
width: 100%;
padding: 0.05rem 0;
border-top: 0.01rem solid rgb(243, 241, 241);
}
.link {
width: 33.33%;
color: #969799;
flex-direction: column; /*列显示*/
}
span {
font-size: 0.26rem;
text-decoration: none !important;
}
img{
width:0.5rem;
height:0.5rem;
}
.active{
color: #257CFF;
}
</style>