index.vue 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. import swiper from 'swiper'
  12. export default {
  13. name: 'simple-swiper',
  14. components: {
  15. Swiper,
  16. SwiperSlide,
  17. },
  18. props: {
  19. imageList: {
  20. type: Array,
  21. default: () => [],
  22. },
  23. autoplay: {
  24. type: Boolean,
  25. default: true,
  26. },
  27. pagination: {
  28. type: Boolean,
  29. default: true,
  30. },
  31. loop: {
  32. type: Boolean,
  33. default: true,
  34. },
  35. },
  36. data() {
  37. const swiperOption = {}
  38. swiperOption.autoplay = this.autoplay
  39. swiperOption.loop = this.loop
  40. if (this.pagination) {
  41. swiperOption.pagination = {
  42. el: '.swiper-pagination',
  43. clickable: true,
  44. }
  45. }
  46. return {
  47. swiperOption,
  48. }
  49. },
  50. }
  51. </script>
  52. <style scoped lang="scss">
  53. .simple-swiper {
  54. height: 100%;
  55. ::v-deep {
  56. .swiper-pagination-bullet-active {
  57. background: #535353;
  58. }
  59. }
  60. .slide {
  61. display: block;
  62. width: 100%;
  63. object-fit: cover;
  64. }
  65. }
  66. </style>