zoukankan      html  css  js  c++  java
  • vue 中使用 VueAwesomeSwiper.js 轮播

    npm install vue-awesome-swiper                                              //版本 4.1.1

    //在main.js中 切记要对应好版本,不然引入的路径可能不一样

    import VueAwesomeSwiper from 'vue-awesome-swiper'
    import 'swiper/css/swiper.min.css'
    Vue.use(VueAwesomeSwiper)
     
     
    //template内部
    <div>
                  <swiper ref="mySwiper" :options="swiperOption">
                    <!-- 渲染的图片 -->
                    <swiper-slide v-for="(item,index) in items" :key="index">
                      <img width="100%" height="100%" :large="item.parentSrc" preview="index" :src="item.imageSrc" alt="">
                    </swiper-slide>
                  <!-- 这是轮播的小圆点 -->

                  </swiper>
                  <div id="prev" slot="button-prev" class="swiper-button-prev" />
                  <div id="next" slot="button-next" class="swiper-button-next" />
    </div>
     
     
    js://一个页面有多个轮播   就设置多个swiperOption
    swiperOption1: {
            autoplay: { disableOnInteraction: false }, // 主要处理点击以后不轮播的bug
            loop: false,
            slidesPerView: 4,
            spaceBetween: 20,
            speed: 800,
            // 用户操作swiper之后,是否禁止autoplay.默认为true:停止。
            autoplayDisableOnInteraction: false,
            // 拖动释放时不会输出信息,阻止click冒泡。拖动Swiper时阻止click事件。
            preventLinksPropagation: true,
            // 设置点击箭头
            navigation: {
              nextEl: '#next',
              prevEl: '#prev'
            }
          },
          swiperOption2: {
            autoplay: { disableOnInteraction: false }, // 主要处理点击以后不轮播的bug
            loop: false,
            delay: 2000,
            slidesPerView: 3,
            spaceBetween: 20,
            speed: 1000,
            // 用户操作swiper之后,是否禁止autoplay.默认为true:停止。
            autoplayDisableOnInteraction: false,
            // 拖动释放时不会输出信息,阻止click冒泡。拖动Swiper时阻止click事件。
            preventLinksPropagation: true,
            // 设置点击箭头
            navigation: {
              nextEl: '#next1',
              prevEl: '#prev1'
            }, on: {
              slideChangeTransitionStart: function() {
                console.log(this.activeIndex)
                // 播放警报
                // if (_this.warningItems[this.activeIndex].new) {
                //   setTimeout(() => {
                //     _this.$refs.playBtn.click()
                //   }, 6000)
                // }
              }
            }
          },
     
     
     
     
     
     
     
  • 相关阅读:
    面试题:给定一个长度为N的数组,其中每个元素的取值范围都是1到N。判断数组中是否有重复的数字
    位运算技巧3
    Android消息循环分析
    ubuntu安装软件的方式
    fragment Trying to instantiate a class com.example.testhuanxindemo.MyFragment that is not a Fragmen
    LAN路由
    php 简易验证码(GD库)
    飘逸的python
    它们,不能是虚函数!!!
    HTML5调用摄像头实现拍照功能(兼容各大主流浏览器)
  • 原文地址:https://www.cnblogs.com/-youth/p/13930395.html
Copyright © 2011-2022 走看看