|
20 | 20 | @animationfinish="handleAnimationfinish" |
21 | 21 | > |
22 | 22 | <swiper-item v-for="(item, index) in list" :key="index" class="wd-swiper__item"> |
23 | | - <image |
24 | | - v-if="isImage(item)" |
25 | | - :src="isObj(item) ? item[valueKey] : item" |
26 | | - :class="`wd-swiper__image ${customImageClass} ${customItemClass} ${getCustomItemClass(currentValue, index, list)}`" |
27 | | - :style="{ height: addUnit(height) }" |
28 | | - :mode="imageMode" |
29 | | - @click="handleClick(index, item)" |
30 | | - /> |
31 | 23 | <video |
32 | | - v-else-if="isVideo(item)" |
| 24 | + v-if="isVideo(item)" |
33 | 25 | :id="`video-${index}-${uid}`" |
34 | 26 | :style="{ height: addUnit(height) }" |
35 | 27 | :src="isObj(item) ? item[valueKey] : item" |
|
44 | 36 | objectFit="cover" |
45 | 37 | @click="handleClick(index, item)" |
46 | 38 | /> |
| 39 | + <image |
| 40 | + v-else |
| 41 | + :src="isObj(item) ? item[valueKey] : item" |
| 42 | + :class="`wd-swiper__image ${customImageClass} ${customItemClass} ${getCustomItemClass(currentValue, index, list)}`" |
| 43 | + :style="{ height: addUnit(height) }" |
| 44 | + :mode="imageMode" |
| 45 | + @click="handleClick(index, item)" |
| 46 | + /> |
| 47 | + |
47 | 48 | <text v-if="isObj(item) && item[textKey]" :class="`wd-swiper__text ${customTextClass}`" :style="customTextStyle">{{ item[textKey] }}</text> |
48 | 49 | </swiper-item> |
49 | 50 | </swiper> |
@@ -137,10 +138,12 @@ const swiperIndicator = computed(() => { |
137 | 138 | }) |
138 | 139 |
|
139 | 140 | const getMediaType = (item: string | SwiperList, type: 'video' | 'image') => { |
| 141 | + const checkType = (url: string) => (type === 'video' ? isVideoUrl(url) : isImageUrl(url)) |
| 142 | +
|
140 | 143 | if (isObj(item)) { |
141 | | - return item.type ? item.type === type : type === 'video' ? isVideoUrl(item[props.valueKey]) : isImageUrl(item[props.valueKey]) |
| 144 | + return item.type && ['video', 'image'].includes(item.type) ? item.type === type : checkType(item[props.valueKey]) |
142 | 145 | } else { |
143 | | - return type === 'video' ? isVideoUrl(item) : isImageUrl(item) |
| 146 | + return checkType(item) |
144 | 147 | } |
145 | 148 | } |
146 | 149 |
|
|
0 commit comments