index.vue 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <template>
  2. <swiper class="swiper simple-swiper" :options="swiperOption">
  3. <swiper-slide v-for="(item, index) in imageList" :key="index">
  4. <div class="slide-content"><img :src="item" class="slide" /></div>
  5. </swiper-slide>
  6. <div class="swiper-pagination" slot="pagination"></div>
  7. </swiper>
  8. </template>
  9. <script>
  10. import { Swiper, SwiperSlide } from 'vue-awesome-swiper'
  11. export default {
  12. name: 'simple-swiper',
  13. components: {
  14. Swiper,
  15. SwiperSlide,
  16. },
  17. props: {
  18. imageList: {
  19. type: Array,
  20. default: () => [],
  21. },
  22. autoplay: {
  23. type: Boolean,
  24. default: true,
  25. },
  26. },
  27. data() {
  28. return {
  29. swiperOption: {
  30. pagination: {
  31. el: '.swiper-pagination',
  32. clickable: true,
  33. },
  34. autoplay: this.autoplay,
  35. loop: true,
  36. },
  37. }
  38. },
  39. }
  40. </script>
  41. <style scoped lang="scss">
  42. .simple-swiper {
  43. height: 100%;
  44. ::v-deep {
  45. .swiper-pagination-bullet-active {
  46. background: #535353;
  47. }
  48. }
  49. .slide {
  50. display: block;
  51. width: 100%;
  52. object-fit: cover;
  53. }
  54. }
  55. </style>