美文网首页
vue中添加swiper

vue中添加swiper

作者: JSONYUAN | 来源:发表于2019-01-15 18:05 被阅读0次

vue中添加swiper

//引入包
import VueAwesomeSwiper from 'vue-awesome-swiper'
Vue.use(VueAwesomeSwiper)
//样式
require('swiper/dist/css/swiper.css')
Vue.use(VueAwesomeSwiper)
//此代码在main.js中引入
//然后在需要的地方执行下边代码 在template中执行
<swiper :options="swiperOption">
        <swiper-slide
          v-for="(items,index) in bannerphoto"
          :key="index"
        >
          <img
            :src="items"
            alt=""
          >
        </swiper-slide>
        <div
          class="swiper-pagination"
          slot="pagination"
        ></div>
      </swiper>

//在data中执行
bannerphoto: [
        'https://i1.mifile.cn/a4/xmad_15471333544761_iIFgE.jpg',
        'https://i1.mifile.cn/a4/xmad_15475244446497_pOHxm.jpg'
      ],
      swiperOption: {
        pagination: {
          el: '.swiper-pagination'
        },
        paginationClickable: true,
        autoplay: 2500,
        autoplayDisableOnInteraction: true,
        loop: true,
        coverflow: {
          rotate: 30,
          stretch: 10,
          depth: 60,
          modifier: 2,
          slideShadows: true
        }
      }

相关文章

网友评论

      本文标题:vue中添加swiper

      本文链接:https://www.haomeiwen.com/subject/dfaydqtx.html