carousel.vue 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <template>
  2. <div class="carousel">
  3. <div class="container">
  4. <div v-swiper:mySwiper="swiperOption">
  5. <div class="swiper-wrapper">
  6. <div class="swiper-slide" v-for="item in carouselData">
  7. <!--<a :href="banner.hrefUrl" target="_blank" v-if="banner.hrefUrl">-->
  8. <!--<img :src="banner.pictureUrl"/>-->
  9. <!--</a>-->
  10. <span>
  11. <img :src="item.url" style="width:100%;height:100%;">
  12. </span>
  13. </div>
  14. <div class="swiper-button-prev"/>
  15. <div class="swiper-button-next"/>
  16. </div>
  17. <div class="swiper-pagination swiper-pagination-bullets"/>
  18. </div>
  19. <slot/>
  20. </div>
  21. </div>
  22. </template>
  23. <script>
  24. export default {
  25. name: 'Carousel',
  26. props: ['carouselData'],
  27. data () {
  28. return {
  29. activeSlide: 0,
  30. swiperOption: {
  31. autoplay: 6000,
  32. pagination: '.swiper-pagination',
  33. paginationClickable: true,
  34. mousewheel: true,
  35. effect: 'fade',
  36. lazyLoading: true,
  37. loop: true,
  38. prevButton: '.swiper-button-prev',
  39. nextButton: '.swiper-button-next'
  40. }
  41. }
  42. }
  43. }
  44. </script>
  45. <style scoped>
  46. .carousel{
  47. width:100%;
  48. margin:0 auto;
  49. text-align: center;
  50. position:relative;
  51. }
  52. .container{
  53. width:100%;
  54. margin:0 auto;
  55. padding:0;
  56. }
  57. </style>