-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path02.html
72 lines (62 loc) · 1.39 KB
/
02.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
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<title>Tabs</title>
<style>
.clearfix::after {
content: "";
clear: both;
display: block;
}
.tabs {}
.tabs .tabItems {}
.tabs .tabItems .item {
padding: 10px 30px;
float: left;
border-radius: 2px 2px 0px 0px;
margin: 0px 2px;
cursor: pointer;
}
.tabContents .content {
width: 600px;
min-height: 300px;
}
.tabs div div:nth-child(1) {
background-color: skyblue;
}
.tabs div div:nth-child(2) {
background-color: sandybrown;
}
.tabs div div:nth-child(3) {
background-color: gray;
}
</style>
<script src="https://cdn.jsdelivr.net/npm/vue"></script>
</head>
<body>
<div id="app" class="tabs">
<div class="tabItems clearfix">
<div class="item" v-for="(item,index) in tabsItems" @click="toggleTabs(index)">{{item}}</div>
</div>
<div class="tabContents">
<div id="news" v-for="(item,index) in tabsContents" class="content" v-show="nowIndex===index">{{item}}</div>
</div>
</div>
</body>
</html>
<script>
var app = new Vue({
el: '#app',
data: {
tabsItems: ['AAA', 'BBB','CCC'],
tabsContents:['111','222','333'],
nowIndex: 0
},
methods: {
toggleTabs: function(index) {
this.nowIndex = index;
}
}
})
</script>