当前位置:网站首页>Wiper component encapsulation

Wiper component encapsulation

2022-04-23 16:59:00 Endless cake

swiper Components

<!-- Component calls -->
<ui-swipe :product-image="swiperList" :img-event="showImageViewer" key-name="imageUrl"></ui-swipe>
<!-- Component content -->
<template>
  <div class="swipe" @click="imgEvent" style="visibility: 'visible' !important">
    <div class="swipe-wrap">
      <div class="swiper-container">
        <div class="swiper-wrapper">
          <figure class="swiper-slide" v-for="(pic, picIndex) in productImage" :key="picIndex" >
            <template v-if="pic.linkUrl">
              <a :href="pic.linkUrl || 'javascript:void(0)'">
                <img
                  class="h100per"
                  alt="pic"
                  :src="pic[keyName]?pic[keyName]:defaultPic"
                  style="visibility: 'visible' !important"
                />
              </a>
            </template>
            <template v-if="!pic.linkUrl">
              <img
                class="h100per"
                alt="pic"
                :src="pic[keyName]?pic[keyName]:defaultPic"
                style="visibility: 'visible' !important"
              />
            </template>
          </figure>
        </div>
        <div class="swiper-pagination swiper-pagination-red"></div>
      </div>
    </div>
    <slot></slot>
  </div>
</template>
<script>
export default {
  props: ['productImage', 'imgEvent', 'keyName', 'defaultPic'],
  mounted() {
    var that = this
    Vue.nextTick(function() {
      setTimeout(() => {
        // eslint-disable-next-line no-undef
        new Swiper('.swiper-container', {
          autoplay: {
            //  Auto play 
            delay: 3000, // 3s
            stopOnLast: false, //  The last frame plays automatically 
            disableOnInteraction: false //  It can also play normally after manual sliding 
          },
          loop: that.productImage.length > 1, //  Roll back 
          pagination: {
            //  Configure small points 
            el: '.swiper-pagination',
            clickable: true
          }
        })
      }, 200)
    })
  },
  methods: {}
}
</script>

版权声明
本文为[Endless cake]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230554520020.html