-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtab.html
67 lines (64 loc) · 1.42 KB
/
tab.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
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>选项卡</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: #fdd;
}
.tabs div div:nth-child(2){
background-color: #dfd;
}
.tabs div div:nth-child(3){
background-color: #ddf;
}
</style>
</head>
<body>
<script src="https://cdn.jsdelivr.net/npm/vue"></script>
<div class="tabs">
<div class="tabItems clearfix">
<div class="item" v-for="(item,index) in tabs" @click="clickIt(index)">{{item}}</div>
</div>
<div class="tabContents">
<div class="content" v-for="(item,index) in tabContents" v-show="nowindex==index">{{item}}</div>
</div>
</div>
<script type="text/javascript">
var app=new Vue({
el:".tabs",
data:{
tabs:['新闻','通知','公告'],
tabContents:['新闻内容','通知内容','公告内容'],
nowindex:0,
},
methods:{
clickIt:function(i){
this.nowindex=i;
console.log(i);
}
}
});
</script>
</body>
</html>