vue swiper 實現滾動條功能(這個可當元件引入使用)

深夜的我最精神發表於2020-10-08
<template>
  <swiper :options="swiperOption">
    <swiper-slide>
      <slot></slot>
    </swiper-slide>
    <div class="swiper-scrollbar" v-if="scrollbar" slot="scrollbar"></div>
  </swiper>
</template>

<script>
  import { Swiper, SwiperSlide } from 'vue-awesome-swiper'

  export default {
    name: 'swiper-example-scroll-container',
    title: 'Scroll container',
    components: {
      Swiper,
      SwiperSlide
    },
    data() {
      return {
        swiperOption: {
          direction: 'vertical',
          slidesPerView: 'auto',
          freeMode: true,
          setWrapperSize: true,
          scrollbar: {
            el: this.swiper-scrollbar ? '.swiper-scrollbar ' : null,
            hide: true
          }
        }
      }
    },
    props:{
        scrollbar:{
          type: Boolean,
          default: true
        }
    }
  }
</script>

<style lang="scss" scoped>

</style>

 

相關文章