Vue使用Swiper

Posted yangjunbohtml

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Vue使用Swiper相关的知识,希望对你有一定的参考价值。

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,
               },
           });
    },

 

以上是关于Vue使用Swiper的主要内容,如果未能解决你的问题,请参考以下文章

在vue中使用swiper4.x

vue使用swiper的坑-刷新不动,loop属性失效

在vue里引用swiper插件,怎么使用

在vue里引用swiper插件,怎么使用

vue中使用vue-awesome-swiper

Vue使用vue-awesome-swiper最后一个元素显示不全问题