vue-awesome-swiper的使用
1、安裝
npm install vue-awesome-swiper --save-dev
2迁霎、在vue中引入
進(jìn)入maim.js文件
import vueSwiper from 'vue-awesome-swiper'
import 'swiper/dist/css/swiper.css'
Vue.use(vueSwiper)
3吱抚、進(jìn)入輪播圖組件中
<template>
<swiper :options="swiperOption">
<swiper-slide class="swiper-slide" v-for="(item,index) in carouselArr" :key="index">
<img :src="item"/>
</swiper-slide>
<!-- 分頁(yè)器 -->
<div class="swiper-pagination" slot="pagination"></div>
<!-- 左右箭頭 -->
<div class="swiper-button-prev" slot="button-prev"></div>
<div class="swiper-button-next" slot="button-next"></div>
</swiper>
</template>
<script>
export default {
data(){
return {
swiperOption:{
//顯示分頁(yè)
pagination: {
el: '.swiper-pagination'
},
//設(shè)置點(diǎn)擊箭頭
navigation: {
nextEl: '.swiper-button-next',
prevEl: '.swiper-button-prev'
},
//自動(dòng)輪播
autoplay: {
delay: 2000,
//當(dāng)用戶滑動(dòng)圖片后繼續(xù)自動(dòng)輪播
disableOnInteraction: false,
},
//開(kāi)啟循環(huán)模式
loop: true
}
}
}
}
</script>