提交 | 用户 | 时间
|
820397
|
1 |
<template> |
H |
2 |
<!-- 无图片 --> |
|
3 |
<div |
|
4 |
class="h-250px flex items-center justify-center bg-gray-3" |
|
5 |
v-if="property.items.length === 0" |
|
6 |
> |
|
7 |
<Icon icon="tdesign:image" class="text-gray-8 text-120px!" /> |
|
8 |
</div> |
|
9 |
<div v-else class="relative"> |
|
10 |
<el-carousel |
|
11 |
height="174px" |
|
12 |
:type="property.type === 'card' ? 'card' : ''" |
|
13 |
:autoplay="property.autoplay" |
|
14 |
:interval="property.interval * 1000" |
|
15 |
:indicator-position="property.indicator === 'number' ? 'none' : undefined" |
|
16 |
@change="handleIndexChange" |
|
17 |
> |
|
18 |
<el-carousel-item v-for="(item, index) in property.items" :key="index"> |
|
19 |
<el-image class="h-full w-full" :src="item.imgUrl" /> |
|
20 |
</el-carousel-item> |
|
21 |
</el-carousel> |
|
22 |
<div |
|
23 |
v-if="property.indicator === 'number'" |
|
24 |
class="absolute bottom-10px right-10px rounded-xl bg-black p-x-8px p-y-2px text-10px text-white opacity-40" |
|
25 |
>{{ currentIndex }} / {{ property.items.length }}</div |
|
26 |
> |
|
27 |
</div> |
|
28 |
</template> |
|
29 |
<script setup lang="ts"> |
|
30 |
import { CarouselProperty } from './config' |
|
31 |
|
|
32 |
/** 轮播图 */ |
|
33 |
defineOptions({ name: 'Carousel' }) |
|
34 |
|
|
35 |
defineProps<{ property: CarouselProperty }>() |
|
36 |
|
|
37 |
const currentIndex = ref(0) |
|
38 |
const handleIndexChange = (index: number) => { |
|
39 |
currentIndex.value = index + 1 |
|
40 |
} |
|
41 |
</script> |
|
42 |
|
|
43 |
<style scoped lang="scss"></style> |