banner.vue 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <template>
  2. <div class="banner">
  3. <div v-swiper:mySwiper="swiperOption" class="swiper-container" refs="Vswiper">
  4. <div class="swiper-wrapper">
  5. <div class="swiper-slide" v-for="banner in banners">
  6. <a>
  7. <img :src="banner.pictureLink"/>
  8. </a>
  9. </div>
  10. <div v-show="banners.length > 1" class="swiper-button-prev"><i class="iconfont icon-swiper-left"></i></div>
  11. <div v-show="banners.length > 1" class="swiper-button-next"><i class="iconfont icon-swiper-right"></i></div>
  12. </div>
  13. <div v-show="banners.length > 1" class="swiper-pagination swiper-pagination-bullets"></div>
  14. </div>
  15. </div>
  16. </template>
  17. <script>
  18. export default {
  19. name: 'BannerView',
  20. data () {
  21. return {
  22. swiperOption: {
  23. autoplay: 6000,
  24. pagination: '.swiper-pagination',
  25. // 解决点击分页器后图片就不能轮播的问题
  26. autoplayDisableOnInteraction: false,
  27. paginationClickable: true,
  28. mousewheelControl: false,
  29. effect: 'fade',
  30. lazyLoading: true,
  31. observer: true,
  32. loop: true,
  33. prevButton: '.swiper-button-prev',
  34. nextButton: '.swiper-button-next'
  35. }
  36. }
  37. },
  38. computed: {
  39. banners () {
  40. return this.$store.state.supplier.detail.banner.data.data || []
  41. }
  42. },
  43. mounted() {
  44. this.$nextTick(() => {
  45. this.mySwiper.update()
  46. })
  47. }
  48. }
  49. </script>
  50. <style type="text/scss" lang="scss" scoped>
  51. .banner{
  52. height:400px;
  53. background: url(/images/supplier/banner.png)no-repeat center center;
  54. margin-bottom:15px;
  55. border-radius:5px;
  56. overflow: hidden;
  57. }
  58. </style>