源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

vue2.0使用swiper组件实现轮播效果

  • 时间:2020-12-11 12:48 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:vue2.0使用swiper组件实现轮播效果
轻松实现vue2.0轮播效果,供大家参考,具体内容如下 1、安装swiper
npm install swiper@3.4.1 --save-dev
2、引用组件
import Swiper from 'swiper';
import 'swiper/dist/css/swiper.min.css';
3、html页面代码
 <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、初始化组件,并设置参数
 setTimeout(function () {
  state.swiperObj = new Swiper('#swiper', {
  loop: true,
  pagination: '.swiper-pagination',
  autoplay: 2000,
  paginationClickable: true
  });
 }, 100)
5、搞定,ok 以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持编程素材网。
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部