• 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)
                // }
              }
            }
          },
     
     
     
     
     
     
     
  • 相关阅读:
    Pyinstaller打包程序,运行时提示ModuleNotFoundError: No module named ‘pikepdf._cpphelpers’的解决办法
    Tkinter设置askopenfilename通过filetypes指定只能打开某一种格式的文件时,不能打开文件选择器
    Tkinter设置的回调函数程序运行自动执行,点击按钮没有执行回调函数
    写Python爬虫遇到的一些坑
    【Golang】【Lite IDE】Go语言环境安装及开发工具Lite IDE的安装
    VUE--当前页面请求定时器,其他页面不需要
    Cascader 级联选择器-------------子级全选则传父级, 子级未全选则传子级
    数组去重
    上传头像后导航栏中头像同步(Vue中监听sessionStorage)
    ui-app打包创建新证书
  • 原文地址:https://www.cnblogs.com/-youth/p/13930395.html
Copyright © 2020-2023  润新知