-
Notifications
You must be signed in to change notification settings - Fork 1
/
menu.html
135 lines (121 loc) · 3.43 KB
/
menu.html
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<link rel="stylesheet" href="../css/vue.css">
<style>
.navul {
width: 200px;
height: 1000px;
background-color: #ddd;
border: 1px dotted #457896;
}
* {
margin: 0;
padding: 0;
list-style: none;
text-decoration: none;
}
#app {
position: absolute;
left: 50%;
transform: translateX(-50%);
}
.navul {
padding: 10px;
}
.navul > li {
padding: 5px 0;
border-bottom: 1px dashed #fff;
}
.navul li a {
color: #457896;
}
.fade-enter-active, .fade-leave-active {
transition: all 1s ease;
}
.fade-enter, .fade-leave-to {
transform: translateX(100px);
opacity: 0;
}
.fade-enter-to, .fade-leave {
opacity: 1;
}
.hide {
display: none;
}
a.active {
color: #ec6237 !important;
}
</style>
</head>
<body>
<template id='navTemp'>
<ul class="navul">
<li v-for="(navItem, i) in mynavData">
<template v-if="navItem.item">
<a href="javascript: void(0)" @click="toggleShow(i)" :class="{active: indexGroup[i]}">
{{ navItem.value }}
</a>
<transition name="fade">
<ul v-if="indexGroup[i]" class="oneul">
<li v-for="(one, j) in navItem.item">
<a href="javascript: void(0)" @click="toggleShow(i, j)" :class="{active: indexGroup[i * 10 + j]}">{{ one }}</a>
</li>
</ul>
</transition>
</template>
<template v-else>
<a href="javascript: void(0)" @click="toggleShow(i)" :class="{active: indexGroup[i]}">{{ navItem.value }}</a>
</template>
</li>
</ul>
</template>
<div id="app">
<my-nav :mynav-Data="navData"></my-nav>
</div>
</body>
</html>
<script type="text/javascript" src="../script/api.js"></script>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<script>
Vue.component('my-nav', {
props: ['mynavData'],
template: '#navTemp',
data() {
return {
indexGroup: {}
}
},
methods: {
toggleShow: function(i, j) {
if(j != undefined) {
var index = i * 10 + j;
this.changeValue(index)
} else {
this.changeValue(i)
}
},
changeValue: function(k) {
if(this.indexGroup[k]) {
this.$set(this.indexGroup, k, false)
} else {
this.$set(this.indexGroup, k, true)
}
}
}
})
new Vue({
el: '#app',
data: {
navData: [
{name: 'desc', value: 'Biu'},
{name: 'job', value: 'Web', item: ['app', 'program']},
{name: 'person', value: 'appearance', item: ['tall', 'weight']}
]
}
})
</script>