index.vue 1005 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <template>
  2. <div class="simple-swiper">
  3. <swiper ref="mySwiper" :options="swiperOptions">
  4. <swiper-slide v-for="(item, index) in imageList" :key="index">
  5. <div class="slide"><img class="image" :src="item" /></div>
  6. </swiper-slide>
  7. </swiper>
  8. </div>
  9. </template>
  10. <script>
  11. import { Swiper, SwiperSlide, directive } from 'vue-awesome-swiper'
  12. export default {
  13. components: {
  14. Swiper,
  15. SwiperSlide,
  16. },
  17. directives: {
  18. swiper: directive,
  19. },
  20. props: {
  21. imageList: {
  22. type: Array,
  23. default: () => [],
  24. },
  25. },
  26. data() {
  27. return {
  28. swiperOptions: {
  29. autoplay: true,
  30. },
  31. }
  32. },
  33. computed: {
  34. swiper() {
  35. return this.$refs.mySwiper.$swiper
  36. },
  37. },
  38. mounted() {
  39. console.log('Current Swiper instance object', this.swiper)
  40. },
  41. }
  42. </script>
  43. <style scoped lang="scss">
  44. .simple-swiper {
  45. width: 100%;
  46. height: 100%;
  47. overflow: hidden;
  48. .image {
  49. display: block;
  50. width: 100%;
  51. height: 100%;
  52. }
  53. }
  54. </style>