码迷,mamicode.com
首页 > 其他好文 > 详细

vue-awesome-swiper

时间:2017-10-27 01:17:19      阅读:197      评论:0      收藏:0      [点我收藏+]

标签:not   class   必须   swipe   index   rac   recommend   key   main   

npm install vue-awesome-sw

 1 main.js
import VueAwesomeSwiper from ‘vue-awesome-swiper‘
Vue.use(VueAwesomeSwiper)
<template> 2 <div> 3 <swiper :options="swiperOption" ref="mySwiper"> 4 <!-- 务必加上key 2.0后--> 5 <swiper-slide v-for="(item,index) in recommends" :key="index"> 6 <img :src="item.picUrl"> 7 </swiper-slide> 8 <div class="swiper-pagination" slot="pagination"></div> 9 </swiper> 10 </div> 11 </template> 12 <script> 13 import { swiper, swiperSlide } from ‘vue-awesome-swiper‘ 14 require(‘swiper/dist/css/swiper.css‘)//必须 不然样式不能生效 15 export default { 16 data () { 17 return { 18 swiperOption: { 19 notNextTick: true, 20 autoplay: 3000, 21 pagination: ‘.swiper-pagination‘, 22 paginationClickable: true, 23 mousewheelControl: true, 24 autoplayDisableOnInteraction: false,//移动端加上这个不然不会滚动 25 loop: true,//环路 26 observeParents: true, 27 onSlideChangeEnd: swiper => { 28 this.page = swiper.realIndex + 1 29 this.index = swiper.realIndex 30 } 31 } 32 } 33 }, 34 components: { 35 swiper, 36 swiperSlide 37 }, 38 computed: { 39 swiper () { 40 return this.$refs.mySwiper.swiper 41 } 42 }, 43 mounted () { 44 this.swiper.slideTo(0, 0, false) 45 } 46 } 47 48 </script>

 

iper --save

vue-awesome-swiper

标签:not   class   必须   swipe   index   rac   recommend   key   main   

原文地址:http://www.cnblogs.com/-maomao-/p/7739677.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!