Github网站链接:vue-awesome-swiper
安装
基于 Swiper4、适用于 Vue 的轮播组件,支持服务端渲染和单页应用。
如果需要回退到 Swiper3,请使用 v2.6.7 版本。
npm install vue-awesome-swiper@2.6.7 --save
引入
/*全局引入*/
import VueAwesomeSwiper from 'vue-awesome-swiper'
import 'swiper/dist/css/swiper.css'
Vue.use(VueAwesomeSwiper)
image.png
使用
Github网站链接:vue-awesome-swiper
<template>
<div class="carrousel">
<swiper :options="swiperOption" ref="mySwiper" v-if="List.length">
<swiper-slide v-for="item of swiperList" :key="item.id">
<img class="BannerImg" :src="item.imgUrl" alt="">
</swiper-slide>
<div class="swiper-pagination" slot="pagination"></div>
</swiper>
</div>
</template>
<script>
export default {
name: 'carrousel',
data () {
return {
swiperOption: {
// 参数选项,显示小点
pagination: '.swiper-pagination',
//循环
loop: true,
//每张播放时长3秒,自动播放
autoplay: 3000,
//滑动速度
speed: 1000,
// false: 触碰后自动切换也不会停止
autoplayDisableOnInteraction: false
},
swiperList: [{
id: '001',
imgUrl: 'http://img1.qunarzz.com/piao/fusion/1805/d4/d41d77b6ba8aca02.jpg_750x200_ac3d9a73.jpg'
}, {
id: '002',
imgUrl: 'http://img1.qunarzz.com/piao/fusion/1805/f1/e57bc93226317102.jpg_750x200_9ab37bd0.jpg'
}, {
id: '003',
imgUrl: 'http://img1.qunarzz.com/piao/fusion/1804/c4/1cdd28811593b802.jpg_750x200_5fbb7c91.jpg'
}]
}
}
}
</script>
<style lang="stylus" scoped>
.carrousel >>> .swiper-pagination-bullet-active
width: .3rem;
height: .3rem;
background: red;
.carrousel >>> .swiper-pagination-bullet
width: .3rem;
height: .3rem;
.carrousel
overflow hidden
width 100%
height 0
padding-bottom 26.67%
.BannerImg
width 100vw
</style>
网友评论