1
- <script setup lang="ts">
2
- import type { AutoplayOptions , SwiperModule , Swiper as SwiperType } from " swiper/types" ;
1
+ <script lang="ts" setup >
2
+ import type { AutoplayOptions , Swiper as SwiperType , SwiperModule } from " swiper/types" ;
3
3
import { useMutationObserver } from " @vueuse/core" ;
4
4
import {
5
5
Autoplay ,
@@ -67,16 +67,16 @@ const props = withDefaults(defineProps<Props>(), {
67
67
68
68
const slideList = computed <SlideItem []>(() => {
69
69
return (
70
- props .items ?.map ((link ) => {
71
- if (typeof link === " string" ) return { link };
72
- return link ;
73
- }) ?? []
70
+ props .items ?.map ((link ) => {
71
+ if (typeof link === " string" ) return { link };
72
+ return link ;
73
+ }) ?? []
74
74
);
75
75
});
76
76
77
77
function parseSize(size : number | string ) {
78
78
if (typeof size === " number" ) {
79
- return ` ${size }px ` ;
79
+ return ` ${ size }px ` ;
80
80
}
81
81
return size ;
82
82
}
@@ -123,7 +123,7 @@ const autoplay = computed<AutoplayOptions | boolean>(() => {
123
123
});
124
124
125
125
const hasNavigation = computed (() =>
126
- props .mode === " banner" || props .mode === " broadcast" ? props .navigation : false
126
+ props .mode === " banner" || props .mode === " broadcast" ? props .navigation : false
127
127
);
128
128
129
129
let swiper: SwiperType ;
@@ -139,13 +139,13 @@ function onSwiper(_swiper: SwiperType) {
139
139
onMounted (() => {
140
140
if (props .mode === " carousel" && ! props .pauseOnMouseEnter ) {
141
141
useMutationObserver (
142
- () => document .documentElement ,
143
- () => {
144
- if (! swiper ) return ;
145
- swiper .wrapperEl .style .transform = " translate3d(0px, 0px, 0px)" ;
146
- setTimeout (() => swiper .update (), 350 );
147
- },
148
- { attributeFilter: [" data-theme" ] }
142
+ () => document .documentElement ,
143
+ () => {
144
+ if (! swiper ) return ;
145
+ swiper .wrapperEl .style .transform = " translate3d(0px, 0px, 0px)" ;
146
+ setTimeout (() => swiper .update (), 350 );
147
+ },
148
+ { attributeFilter: [" data-theme" ] }
149
149
);
150
150
}
151
151
});
@@ -154,44 +154,44 @@ onMounted(() => {
154
154
<template >
155
155
<ClientOnly >
156
156
<Swiper
157
- class = " vp-swiper "
158
- :class =" { 'swiper-no-swiping': mode === 'banner' ? !swipe : mode === 'carousel' }"
159
- :style = " styles "
160
- :modules = " modules "
161
- :autoplay = " autoplay "
162
- :navigation =" hasNavigation"
163
- :pagination ="
157
+ :autoplay = " autoplay "
158
+ :class =" { 'swiper-no-swiping': mode === 'banner' ? !swipe : mode === 'carousel' }"
159
+ :effect = " mode === 'banner' ? effect : 'slide' "
160
+ :loop = " loop "
161
+ :modules = " modules "
162
+ :navigation =" hasNavigation"
163
+ :pagination ="
164
164
props.mode !== 'carousel'
165
165
? {
166
166
dynamicBullets: true,
167
167
clickable: true
168
168
}
169
169
: false
170
170
"
171
- :speed =" speed"
172
- :loop = " loop "
173
- :effect = " mode === 'banner' ? effect : 'slide' "
174
- lazy
175
- v-bind =" $attrs"
176
- @swiper =" onSwiper"
171
+ :speed =" speed"
172
+ :style = " styles "
173
+ class = " vp-swiper "
174
+ lazy
175
+ v-bind =" $attrs"
176
+ @swiper =" onSwiper"
177
177
>
178
178
<SwiperSlide v-for =" (item, index) in slideList" :key =" 'general-' + index" >
179
179
<a
180
- v-if =" item.href && item.link"
181
- :href =" item.href"
182
- target = " _blank "
183
- rel =" noopener noreferrer"
184
- class = " swiper-slide-link no-icon "
180
+ v-if =" item.href && item.link"
181
+ :href =" item.href"
182
+ class = " swiper-slide-link no-icon "
183
+ rel =" noopener noreferrer"
184
+ target = " _blank "
185
185
>
186
- <img class =" swiper-slide-custom-container swiper-slide-img" :src = " item.link " :alt = " item.alt " />
186
+ <img :alt = " item.alt " :src = " item.link " class =" swiper-slide-custom-container swiper-slide-img" />
187
187
</a >
188
188
<div v-else-if =" item.alt" class =" swiper-slide-custom-container" >
189
189
<a
190
- v-if =" item.href"
191
- :href =" item.href"
192
- target = " _blank "
193
- rel =" noopener noreferrer"
194
- class = " swiper-slide-text-link "
190
+ v-if =" item.href"
191
+ :href =" item.href"
192
+ class = " swiper-slide-text-link "
193
+ rel =" noopener noreferrer"
194
+ target = " _blank "
195
195
>
196
196
<div class =" swiper-slide-text" >{{ item.alt }}</div >
197
197
</a >
0 commit comments