vue使用原生swiper代碼實(shí)例
這篇文章主要介紹了vue使用原生swiper代碼實(shí)例,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下
代碼如下
<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實(shí)例 } }, 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標(biāo)簽引入樣式
script標(biāo)簽引入js
以上就是本文的全部內(nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
element的表單校驗(yàn)證件號(hào)規(guī)則及輸入“無”的情況校驗(yàn)通過(示例代碼)
這篇文章主要介紹了element的表單校驗(yàn)證件號(hào)規(guī)則及輸入“無”的情況校驗(yàn)通過,使用方法對(duì)校驗(yàn)數(shù)據(jù)進(jìn)行過濾判斷,本文通過示例代碼給大家介紹的非常詳細(xì),感興趣的朋友一起看看吧2023-11-11elementui使用el-upload組件實(shí)現(xiàn)自定義上傳的詳細(xì)步驟
upload上傳是前端開發(fā)很常用的一個(gè)功能,在Vue開發(fā)中常用的Element組件庫也提供了非常好用的upload組件,這篇文章主要給大家介紹了關(guān)于elementui使用el-upload組件實(shí)現(xiàn)自定義上傳的詳細(xì)步驟,需要的朋友可以參考下2023-12-12vue2.0+webpack環(huán)境的構(gòu)造過程
本文分步驟給大家介紹了vue2.0+webpack環(huán)境的構(gòu)造過程的相關(guān)資料,非常不錯(cuò)具有參考借鑒價(jià)值,需要的朋友可以參考下2016-11-11Vue單頁式應(yīng)用(Hash模式下)實(shí)現(xiàn)微信分享的實(shí)例
本篇文章介紹了Vue單頁式應(yīng)用(Hash模式下)實(shí)現(xiàn)微信分享的實(shí)例,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-07-07Vue監(jiān)聽滾動(dòng)實(shí)現(xiàn)錨點(diǎn)定位(雙向)示例
今天小編大家分享一篇Vue監(jiān)聽滾動(dòng)實(shí)現(xiàn)錨點(diǎn)定位(雙向)示例,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧2019-11-11Vue動(dòng)態(tài)樣式方法實(shí)例總結(jié)
在vue項(xiàng)目中,很多場景要求我們動(dòng)態(tài)改變?cè)氐臉邮?下面這篇文章主要給大家介紹了關(guān)于Vue動(dòng)態(tài)樣式方法的相關(guān)資料,文中通過實(shí)例代碼介紹的非常詳細(xì),需要的朋友可以參考下2023-02-02