mirror of
https://gitee.com/wot-design-uni/wot-design-uni.git
synced 2025-12-06 17:18:40 +08:00
feat: ✨ Swiper 轮播项type字段的处理逻辑限制在可选值范围内 (#785)
This commit is contained in:
parent
b1f42af640
commit
1fd0a27788
@ -212,7 +212,6 @@ const current6 = ref<number>(0)
|
|||||||
const current7 = ref<number>(0)
|
const current7 = ref<number>(0)
|
||||||
const current8 = ref<number>(0)
|
const current8 = ref<number>(0)
|
||||||
const current9 = ref<number>(0)
|
const current9 = ref<number>(0)
|
||||||
const current10 = ref<number>(0)
|
|
||||||
|
|
||||||
const isLoop = ref(false)
|
const isLoop = ref(false)
|
||||||
|
|
||||||
|
|||||||
@ -20,16 +20,8 @@
|
|||||||
@animationfinish="handleAnimationfinish"
|
@animationfinish="handleAnimationfinish"
|
||||||
>
|
>
|
||||||
<swiper-item v-for="(item, index) in list" :key="index" class="wd-swiper__item">
|
<swiper-item v-for="(item, index) in list" :key="index" class="wd-swiper__item">
|
||||||
<image
|
|
||||||
v-if="isImage(item)"
|
|
||||||
:src="isObj(item) ? item[valueKey] : item"
|
|
||||||
:class="`wd-swiper__image ${customImageClass} ${customItemClass} ${getCustomItemClass(currentValue, index, list)}`"
|
|
||||||
:style="{ height: addUnit(height) }"
|
|
||||||
:mode="imageMode"
|
|
||||||
@click="handleClick(index, item)"
|
|
||||||
/>
|
|
||||||
<video
|
<video
|
||||||
v-else-if="isVideo(item)"
|
v-if="isVideo(item)"
|
||||||
:id="`video-${index}-${uid}`"
|
:id="`video-${index}-${uid}`"
|
||||||
:style="{ height: addUnit(height) }"
|
:style="{ height: addUnit(height) }"
|
||||||
:src="isObj(item) ? item[valueKey] : item"
|
:src="isObj(item) ? item[valueKey] : item"
|
||||||
@ -44,6 +36,15 @@
|
|||||||
objectFit="cover"
|
objectFit="cover"
|
||||||
@click="handleClick(index, item)"
|
@click="handleClick(index, item)"
|
||||||
/>
|
/>
|
||||||
|
<image
|
||||||
|
v-else
|
||||||
|
:src="isObj(item) ? item[valueKey] : item"
|
||||||
|
:class="`wd-swiper__image ${customImageClass} ${customItemClass} ${getCustomItemClass(currentValue, index, list)}`"
|
||||||
|
:style="{ height: addUnit(height) }"
|
||||||
|
:mode="imageMode"
|
||||||
|
@click="handleClick(index, item)"
|
||||||
|
/>
|
||||||
|
|
||||||
<text v-if="isObj(item) && item[textKey]" :class="`wd-swiper__text ${customTextClass}`" :style="customTextStyle">{{ item[textKey] }}</text>
|
<text v-if="isObj(item) && item[textKey]" :class="`wd-swiper__text ${customTextClass}`" :style="customTextStyle">{{ item[textKey] }}</text>
|
||||||
</swiper-item>
|
</swiper-item>
|
||||||
</swiper>
|
</swiper>
|
||||||
@ -137,10 +138,12 @@ const swiperIndicator = computed(() => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
const getMediaType = (item: string | SwiperList, type: 'video' | 'image') => {
|
const getMediaType = (item: string | SwiperList, type: 'video' | 'image') => {
|
||||||
|
const checkType = (url: string) => (type === 'video' ? isVideoUrl(url) : isImageUrl(url))
|
||||||
|
|
||||||
if (isObj(item)) {
|
if (isObj(item)) {
|
||||||
return item.type ? item.type === type : type === 'video' ? isVideoUrl(item[props.valueKey]) : isImageUrl(item[props.valueKey])
|
return item.type && ['video', 'image'].includes(item.type) ? item.type === type : checkType(item[props.valueKey])
|
||||||
} else {
|
} else {
|
||||||
return type === 'video' ? isVideoUrl(item) : isImageUrl(item)
|
return checkType(item)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user