无畏无知

博客园 首页 新随笔 联系 订阅 管理

1.下载包

npm install vue-awesome-swiper --save

2.main.js引包

import VueAwesomeSwiper from 'vue-awesome-swiper'
Vue.use(VueAwesomeSwiper)
import 'swiper/dist/css/swiper.css'

3.组件中使用

 <div class="swiper-container">
             <div class="swiper-wrapper">
                 <div class="swiper-slide">Slide 1</div>
                 <div class="swiper-slide">Slide 2</div>
                 <div class="swiper-slide">Slide 3</div>
                 <div class="swiper-slide">Slide 4</div>
                 <div class="swiper-slide">Slide 5</div>
                 <div class="swiper-slide">Slide 6</div>
                 <div class="swiper-slide">Slide 7</div>
                 <div class="swiper-slide">Slide 8</div>
                 <div class="swiper-slide">Slide 9</div>
                 <div class="swiper-slide">Slide 10</div>
             </div>
             <!-- Add Pagination -->
             <div class="swiper-pagination"></div>
         </div>
//引包
import Swiper from 'swiper'
//使用
 mounted(){
        var swiper = new Swiper('.swiper-container', {
               direction: 'vertical',
               slidesPerView: 1,
               spaceBetween: 30,
               mousewheel: true,
               pagination: {
                 el: '.swiper-pagination',
                 clickable: true,
               },
           });
    },

 

posted on 2020-06-15 20:12  无知才无畏  阅读(4521)  评论(0编辑  收藏  举报