vue使用原生swiper代碼實例
更新時間:2020年02月05日 11:20:41 作者:古墩古墩
這篇文章主要介紹了vue使用原生swiper代碼實例,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友可以參考下
這篇文章主要介紹了vue使用原生swiper代碼實例,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友可以參考下
代碼如下
<template>
<div>
<div class="swiper_Box" :class="identify">
<div class="swiper-wrapper" :ref="identify">
<div class="swiper-slide" v-for="(item,index) in imgArr" :key="'swiperSlide'+index">
<div class="bannerItem">
<img :src="item.url" alt="">
</div>
</div>
</div>
<!-- <div v-if="imgArr.length>1" class="swiper-button-prev" slot="button-prev"></div>
<div v-if="imgArr.length>1" class="swiper-button-next" slot="button-next"></div> -->
<div class="swiper-pagination"></div>
</div>
</div>
</template>
<script>
export default {
props:['imgArr','identify','paginationType'],//接收傳來的輪播圖
watch:{
imgArr:{
handler(newVal){
console.log(newVal)
},
immediate:true
},
identify:{
handler(newVal){
console.log("id:"+newVal)
var self=this;
},
immediate:true
}
},
data(){
return{
swiperShow:false,
MySwiper:null,//swiper實例
}
},
created(){
},
mounted(){
var self=this;
self.MySwiper = new Swiper ('.'+self.identify,{
init: true,
observer:true,
observeParents:true,
slidesPerView: 1,
spaceBetween: 0,
keyboard: {
enabled: true,
},
loop: true,
autoplay: {
delay: 8000,
disableOnInteraction: false
},
pagination: {
el: '.swiper-pagination',
clickable: true,
type:self.paginationType?self.paginationType:'bullets'
},
navigation: {
nextEl: '.swiper-button-next',
prevEl: '.swiper-button-prev'
},
});
}
}
</script>
<style scoped>
@import url("../styles/swiperBullet.css");
/* 輪播圖 */
.swiperBox{
width:100%;
}
.swiper_Box{
position: relative;
overflow: hidden;
}
.swiper_Box .bannerItem img{
height:auto;
width:100%;
}
.swiperBox .bannerItem{
width:100%;
text-align: center;
}
.swiperBox .bannerItem img{
height:auto;
width:100%;
}
.swiper-pagination{
position: absolute;
bottom:20px;
left:50%;
transform: translateX(-50%);
}
</style>
swiper的引入形式是link標簽引入樣式
script標簽引入js
以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。
相關文章
element的表單校驗證件號規(guī)則及輸入“無”的情況校驗通過(示例代碼)
這篇文章主要介紹了element的表單校驗證件號規(guī)則及輸入“無”的情況校驗通過,使用方法對校驗數(shù)據(jù)進行過濾判斷,本文通過示例代碼給大家介紹的非常詳細,感興趣的朋友一起看看吧2023-11-11
elementui使用el-upload組件實現(xiàn)自定義上傳的詳細步驟
upload上傳是前端開發(fā)很常用的一個功能,在Vue開發(fā)中常用的Element組件庫也提供了非常好用的upload組件,這篇文章主要給大家介紹了關于elementui使用el-upload組件實現(xiàn)自定義上傳的詳細步驟,需要的朋友可以參考下2023-12-12
vue2.0+webpack環(huán)境的構(gòu)造過程
本文分步驟給大家介紹了vue2.0+webpack環(huán)境的構(gòu)造過程的相關資料,非常不錯具有參考借鑒價值,需要的朋友可以參考下2016-11-11
Vue單頁式應用(Hash模式下)實現(xiàn)微信分享的實例
本篇文章介紹了Vue單頁式應用(Hash模式下)實現(xiàn)微信分享的實例,具有一定的參考價值,感興趣的小伙伴們可以參考一下2017-07-07
Vue監(jiān)聽滾動實現(xiàn)錨點定位(雙向)示例
今天小編大家分享一篇Vue監(jiān)聽滾動實現(xiàn)錨點定位(雙向)示例,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2019-11-11

