|
@@ -1,11 +1,22 @@
|
1
|
1
|
<template>
|
2
|
2
|
<div class="swiper">
|
3
|
3
|
<van-swipe :autoplay="3000" @change="onChange" ref="swipe">
|
4
|
|
- <van-swipe-item v-for="(image, index) in images" :key="index">
|
5
|
|
- <van-image height="300" :src="image.image" @click="onPerView(index)" />
|
|
4
|
+ <van-swipe-item v-for="(item, index) in images" :key="index">
|
|
5
|
+ <van-image height="300" :src="item.image" @click="onPerView(index)" />
|
6
|
6
|
</van-swipe-item>
|
|
7
|
+ <template #indicator>
|
|
8
|
+ <div class="swiper-indicator" ref="indicator">
|
|
9
|
+ <span
|
|
10
|
+ v-for="(item, index) in images"
|
|
11
|
+ :key="index"
|
|
12
|
+ :class="{ active: current === index }"
|
|
13
|
+ >
|
|
14
|
+ {{ item.text }}
|
|
15
|
+ </span>
|
|
16
|
+ </div>
|
|
17
|
+ </template>
|
7
|
18
|
</van-swipe>
|
8
|
|
- <div class="swiper-tabs">
|
|
19
|
+ <!-- <div class="swiper-tabs">
|
9
|
20
|
<van-tabs
|
10
|
21
|
v-model:active="current"
|
11
|
22
|
background="rgba(0, 0, 0, 0.69)"
|
|
@@ -14,19 +25,16 @@
|
14
|
25
|
title-active-color="#d75e3a"
|
15
|
26
|
@click="onClickTab"
|
16
|
27
|
>
|
17
|
|
- <van-tab
|
18
|
|
- v-for="(image, index) in images"
|
19
|
|
- :key="index"
|
20
|
|
- :title="image.text"
|
21
|
|
- >
|
22
|
|
- </van-tab>
|
|
28
|
+ <template v-for="(item, index) in images" :key="index">
|
|
29
|
+ <van-tab :title="item.text" />
|
|
30
|
+ </template>
|
23
|
31
|
</van-tabs>
|
24
|
|
- </div>
|
|
32
|
+ </div> -->
|
25
|
33
|
</div>
|
26
|
34
|
</template>
|
27
|
35
|
|
28
|
36
|
<script>
|
29
|
|
-import { ref } from "vue"
|
|
37
|
+import { ref } from 'vue'
|
30
|
38
|
import {
|
31
|
39
|
Swipe,
|
32
|
40
|
SwipeItem,
|
|
@@ -34,10 +42,10 @@ import {
|
34
|
42
|
ImagePreview,
|
35
|
43
|
Tabs,
|
36
|
44
|
Tab,
|
37
|
|
-} from "vant"
|
|
45
|
+} from 'vant'
|
38
|
46
|
|
39
|
47
|
export default {
|
40
|
|
- name: "swiper",
|
|
48
|
+ name: 'swiper',
|
41
|
49
|
components: {
|
42
|
50
|
[Swipe.name]: Swipe,
|
43
|
51
|
[SwipeItem.name]: SwipeItem,
|
|
@@ -55,9 +63,11 @@ export default {
|
55
|
63
|
setup(props) {
|
56
|
64
|
const current = ref(0)
|
57
|
65
|
const swipe = ref()
|
|
66
|
+ const indicator = ref()
|
58
|
67
|
|
59
|
68
|
const onChange = (index) => {
|
60
|
69
|
current.value = index
|
|
70
|
+ // indicator.value.scrollTo({ left: 1000 })
|
61
|
71
|
}
|
62
|
72
|
const onPerView = (index) => {
|
63
|
73
|
ImagePreview({
|
|
@@ -70,14 +80,15 @@ export default {
|
70
|
80
|
swipe.value.swipeTo(index)
|
71
|
81
|
swipe.value.resize()
|
72
|
82
|
|
73
|
|
- console.log(index, "ongchawng")
|
|
83
|
+ console.log(index, 'ongchawng')
|
74
|
84
|
}
|
75
|
85
|
|
76
|
86
|
// refs.checkbox.toggle();
|
77
|
|
- onPerView
|
|
87
|
+
|
78
|
88
|
return {
|
79
|
89
|
swipe,
|
80
|
90
|
current,
|
|
91
|
+ indicator,
|
81
|
92
|
onChange,
|
82
|
93
|
onPerView,
|
83
|
94
|
onClickTab,
|
|
@@ -101,11 +112,25 @@ export default {
|
101
|
112
|
width: 100%;
|
102
|
113
|
}
|
103
|
114
|
}
|
104
|
|
-.swiper .van-swipe-item {
|
105
|
|
- /* color: #fff;
|
106
|
|
- font-size: 20px;
|
107
|
|
- line-height: 150px;
|
108
|
|
- text-align: center;
|
109
|
|
- background-color: #39a9ed; */
|
|
115
|
+
|
|
116
|
+.swiper-indicator {
|
|
117
|
+ position: absolute;
|
|
118
|
+ bottom: 0;
|
|
119
|
+ left: 0;
|
|
120
|
+ background: rgba(0, 0, 0, 0.69);
|
|
121
|
+ color: #aaa;
|
|
122
|
+ display: flex;
|
|
123
|
+ flex-wrap: nowrap;
|
|
124
|
+ font-size: 0.85em;
|
|
125
|
+
|
|
126
|
+ span {
|
|
127
|
+ display: inline-block;
|
|
128
|
+ padding: 0.8em;
|
|
129
|
+ flex: none;
|
|
130
|
+
|
|
131
|
+ &.active {
|
|
132
|
+ color: #d75e3a;
|
|
133
|
+ }
|
|
134
|
+ }
|
110
|
135
|
}
|
111
|
136
|
</style>
|