輕松實(shí)現(xiàn)vue2.0輪播效果,供大家參考,具體內(nèi)容如下
1、安裝swiper
npm install swiper@3.4.1 --save-dev
2、引用組件
import Swiper from 'swiper'; import 'swiper/dist/css/swiper.min.css';
3、html頁(yè)面代碼
<div class="swiper-container" id="swiper"> <div class="swiper-wrapper"> <div class="swiper-slide" v-for="(item,$index) in detail.imgs"> <a v-on:click="showPreview($index,detail.imgs,swiperObj)"> <figure class="wp-avatar banner"> <img v-cloak :src="item | toQiNiuImg"/> </figure> </a> </div> </div> <!-- Add Pagination --> <div class="swiper-pagination"></div> </div>
4、初始化組件,并設(shè)置參數(shù)
setTimeout(function () { state.swiperObj = new Swiper('#swiper', { loop: true, pagination: '.swiper-pagination', autoplay: 2000, paginationClickable: true }); }, 100)
5、搞定,ok
聲明:本網(wǎng)頁(yè)內(nèi)容旨在傳播知識(shí),若有侵權(quán)等問(wèn)題請(qǐng)及時(shí)與本網(wǎng)聯(lián)系,我們將在第一時(shí)間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com