|
6 | 6 | >
|
7 | 7 | <Icon icon="tdesign:image" class="text-gray-8 text-120px!" />
|
8 | 8 | </div>
|
9 |
| - <!-- 一行一个 --> |
10 |
| - <div |
11 |
| - v-if="property.swiperType === 0" |
12 |
| - class="flex flex-col" |
13 |
| - :style="{ |
14 |
| - paddingLeft: property.pageMargin + 'px', |
15 |
| - paddingRight: property.pageMargin + 'px' |
16 |
| - }" |
17 |
| - > |
18 |
| - <div v-for="(item, index) in property.items" :key="index"> |
19 |
| - <div |
20 |
| - class="img-item" |
21 |
| - :style="{ |
22 |
| - marginBottom: property.imageMargin + 'px', |
23 |
| - borderRadius: property.borderRadius + 'px' |
24 |
| - }" |
25 |
| - > |
26 |
| - <img alt="" :src="item.imgUrl" /> |
27 |
| - <div v-if="item.title" class="title">{{ item.title }}</div> |
28 |
| - </div> |
29 |
| - </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 p-y-2px bottom-10px right-10px rounded-xl bg-black p-x-8px text-10px text-white opacity-40" |
| 25 | + >{{ currentIndex }} / {{ property.items.length }}</div |
| 26 | + > |
30 | 27 | </div>
|
31 |
| - <el-carousel height="174px" v-else :type="property.swiperType === 3 ? 'card' : ''"> |
32 |
| - <el-carousel-item v-for="(item, index) in property.items" :key="index"> |
33 |
| - <div class="img-item" :style="{ borderRadius: property.borderRadius + 'px' }"> |
34 |
| - <img alt="" :src="item.imgUrl" /> |
35 |
| - <div v-if="item.title" class="title">{{ item.title }}</div> |
36 |
| - </div> |
37 |
| - </el-carousel-item> |
38 |
| - </el-carousel> |
39 | 28 | </template>
|
40 | 29 | <script setup lang="ts">
|
41 | 30 | import { CarouselProperty } from './config'
|
42 | 31 |
|
43 |
| -/** 页面顶部导航栏 */ |
44 |
| -defineOptions({ name: 'NavigationBar' }) |
| 32 | +/** 轮播图 */ |
| 33 | +defineOptions({ name: 'Carousel' }) |
45 | 34 |
|
46 |
| -const props = defineProps<{ property: CarouselProperty }>() |
47 |
| -</script> |
| 35 | +defineProps<{ property: CarouselProperty }>() |
48 | 36 |
|
49 |
| -<style scoped lang="scss"> |
50 |
| -.img-item { |
51 |
| - width: 100%; |
52 |
| - position: relative; |
53 |
| - overflow: hidden; |
54 |
| - &:last-child { |
55 |
| - margin: 0 !important; |
56 |
| - } |
57 |
| - /* 图片 */ |
58 |
| - img { |
59 |
| - width: 100%; |
60 |
| - height: 100%; |
61 |
| - display: block; |
62 |
| - } |
63 |
| - .title { |
64 |
| - height: 36px; |
65 |
| - width: 100%; |
66 |
| - background-color: rgba(51, 51, 51, 0.8); |
67 |
| - text-align: center; |
68 |
| - line-height: 36px; |
69 |
| - color: #fff; |
70 |
| - position: absolute; |
71 |
| - bottom: 0; |
72 |
| - left: 0; |
73 |
| - } |
| 37 | +const currentIndex = ref(0) |
| 38 | +const handleIndexChange = (index: number) => { |
| 39 | + currentIndex.value = index + 1 |
74 | 40 | }
|
75 |
| -</style> |
| 41 | +</script> |
| 42 | + |
| 43 | +<style scoped lang="scss"></style> |
0 commit comments