ImageSwiper.vue 955 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <template>
  2. <swiper
  3. class="image-swiper"
  4. circular
  5. :indicator-dots="true"
  6. :autoplay="true"
  7. :interval="2000"
  8. :duration="1000"
  9. >
  10. <swiper-item v-for="(item, key) in images" :key="key">
  11. <view class="item">
  12. <Image
  13. :src="item"
  14. width="100%"
  15. :radius="15"
  16. mode="aspectFill"
  17. @click="onPreviewImage(key)"
  18. />
  19. </view>
  20. </swiper-item>
  21. </swiper>
  22. </template>
  23. <script setup lang="ts">
  24. import { useSwiperImagePreview } from '@/common/composeabe/SwiperImagePreview';
  25. import Image from '@/components/basic/Image.vue';
  26. import type { PropType } from 'vue';
  27. const props = defineProps({
  28. images: {
  29. type: Array as PropType<string[]>,
  30. default: () => [],
  31. },
  32. })
  33. const { onPreviewImage } = useSwiperImagePreview(() => props.images || [])
  34. </script>
  35. <style lang="scss">
  36. .image-swiper {
  37. height: 400rpx;
  38. image {
  39. border-radius: 20rpx;
  40. }
  41. }
  42. </style>