-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathloop.html
More file actions
130 lines (123 loc) · 2.94 KB
/
Copy pathloop.html
File metadata and controls
130 lines (123 loc) · 2.94 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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Examples</title>
<meta name="description" content="">
<meta name="keywords" content="">
<link href="" rel="stylesheet">
<script src="./lib/vue-2.4.0.js"></script>
<script src="./lib/vue-resource-1.3.4.js"></script>
<script src="./lib/vue-router.js"></script>
<link rel="stylesheet" type="text/css" href="./lib/bootstrap-3.3.7.css">
<link rel="stylesheet" href="./lib/index.css">
<style>
ul{
padding: 0;
}
#loop{
width: 100%;
height: 500px;
overflow: hidden;
position: relative;
}
.cir{
display: flex;
flex-direction: row;
position: absolute;
bottom: 20px;
left: 50%;
margin-left: -75px;
}
.circle{
width: 30px;
height: 30px;
border-radius: 50%;
background-color: pink;
border: 1px solid #fff;
margin-right: 20px;
cursor: pointer;
}
.active{
border: 1px solid transparent;
background-color:lightcoral;
}
.pre,.next{
width: 100px;
height: 100px;
line-height: 100px;
text-align: center;
font-size: 120px;
position: absolute;
top: 50%;
margin-top: -50px;
opacity: 0.7;
cursor: pointer;
}
.pre{
left: 50px;
}
.next{
right: 50px;
}
</style>
</head>
<body>
<div id="app">
<banner></banner>
</div>
<template id="tmp">
<div id="loop">
<ul class="banner">
<li v-show="index===x" v-for="(item,index) in imgurl" :key="item.id">
<img :src="item.url">
</li>
</ul>
<ul class="cir">
<li class="circle" @click="change(index)" :class="{active : index===x}" v-for="(item,index) in imgurl"></li>
</ul>
<div @click="pre" class="pre"> < </div>
<div @click="next" class="next"> > </div>
</div>
</template>
</body>
<script>
var comp = {
template:"#tmp",
data(){
return {
x:0,
imgurl:[
{url:"./images/a.jpg"},
{url:"./images/b.jpg"},
{url:"./images/c.jpg"}
]
}
},
methods: {
pre(){
this.x --
console.log(this.x)
if(this.x < 0){
this.x = this.imgurl.length-1
}
},
next(){
this.x ++
if(this.x === this.imgurl.length){
this.x = 0
}
},
change(index){
this.x = index
}
},
}
Vue.component("banner",comp)
var vm =new Vue({
el:'#app',
data:{}
})
</script>
</html>