在vue的项目中引入swiper插件

一、安装swiper npm install swiper
二、引入js文件 import Swiper from "swiper";
三、在main.js引入css文件 import 'swiper/dist/css/swiper.min.css';
四、在需要播放的组件中的mounted
var swiper = new Swiper('.swiper-container', {
pagination: '.swiper-pagination',
nextButton: '.swiper-button-next',
prevButton: '.swiper-button-prev',
paginationClickable: true,
spaceBetween: 30,
centeredSlides: true,
autoplay: 2500,
autoplayDisableOnInteraction: false
});

posted @ 2019-06-25 21:00  糖果豆豆  阅读(5082)  评论(0编辑  收藏  举报