1. 程式人生 > >vue2.0輪播圖

vue2.0輪播圖

2、安裝swiper外掛

3、使用swiper外掛

?

<template>
 <div class="swiper">
   <swiper :options="swiperOption" ref="mySwiper">
     <swiper-slide>
       <img class="swiper-img" src="../../assets/img/swiper1.jpg">
     </swiper-slide>
     <swiper-slide>
       <img class="swiper-img" src="../../assets/img/swiper2.jpg">
     </swiper-slide>
     <swiper-slide>
       <img class="swiper-img" src="../../assets/img/swiper3.jpg">
     </swiper-slide>
     <div class="swiper-pagination"  slot="pagination"></div>
   </swiper>
 </div>
</template>

<script>
export default {
  name: 'HelloSwiper',
  data () {
    return {
      swiperOption: {
        pagination: '.swiper-pagination',
        autoplay: 3000        //設定自動輪播的時間 自由設定
} } }, computed: { swiper () { return this.$refs.mySwiper.swiper } } } </script> <style scoped> .swiper >>> .swiper-pagination-bullet-active{ //將輪播圖藍色的小圓點變成白色 background: white; } </style>