-
Notifications
You must be signed in to change notification settings - Fork 46
/
App.vue
95 lines (93 loc) · 1.77 KB
/
App.vue
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
<style>
body {
padding: 0;
margin: 0;
background: #2196F3;
}
.contacts {
display: flex;
justify-content: center;
border-bottom: 1px solid #fff;
margin-bottom: 1rem;
}
.contact {
color: #fff;
font-size: 14px;
width: 100%;
line-height: 3rem;
text-align: center;
border-bottom: 2px solid rgba(0,0,0,0);
cursor: pointer;
}
.contact.active {
border-bottom: 2px solid #fff;
}
.swiper-box {
height: 600px;
width: 1000px;
margin: auto;
}
.swiper-box .rd-swipe {
height: 500px;
width: 1000px;
}
</style>
<template>
<div id="app">
<div class="swiper-box">
<div class="contacts">
<div
class="contact"
:class="{ 'active': index === swipe.activeIndex }"
v-for="(contact, index) in contacts"
@click="turnTo(index)"
>
{{contact.text}}
</div>
</div>
<rd-swipe :swipe="swipe">
<div class="rd-swipe-item" :style="{ 'background-image': `url(${img})` }" v-for="(img, index) in imgs">
</div>
</rd-swipe>
</div>
</div>
</template>
<script>
import rdSwipe from './Slide.vue'
export default {
data () {
return {
swipe: {
activeIndex: 0
},
contacts: [{
text: 'Page 1'
}, {
text: 'Page 2'
}, {
text: 'Page 3'
}, {
text: 'Page 4'
}],
imgs: [
'http://covteam.u.qiniudn.com/test18.jpg',
'http://covteam.u.qiniudn.com/test19.jpg',
'http://covteam.u.qiniudn.com/test20.jpg',
'http://covteam.u.qiniudn.com/test21.jpg'
]
}
},
components: {
rdSwipe
},
methods: {
turnTo (index) {
this.$children.map(swipe => {
if (swipe.turnTo) {
swipe.turnTo(index)
}
})
}
}
}
</script>