vue-awesome-swiper解决coverflowEffect和loop属性冲突的问题

vue-awesome-swiper解决coverflowEffect和loop属性冲突的问题

coverflowEffect和loop在官网上不能同时使用,但有时需要3D旋转效果和循环同时存在,可以在swiper上增加一个判断就可以使这两个属性同时存在

在这里插入图片描述

<template>
  <div class="swiperTwoBox">
    <swiper
      class="swiper-container"
      :options="swiperTwoOption"
      ref="myTwoSwiper"
      v-if="arr.length>0"
    >
    <!-- 在swiper判断循环的数组长度是否大于0就可以使其循环播放了 -->
      <swiper-slide
        v-for="(item, index) in arr"
        :key="index"
      >
        <img
          class="swiperTwoImg"
          :src="item"
        />
      </swiper-slide>
    </swiper>
  </div>
</template>

<script>
import "swiper/dist/css/swiper.css";
import { swiper, swiperSlide } from "vue-awesome-swiper";
export default {
  components: {
    swiper,
    swiperSlide,
  },
  data() {
    return {
      swiperTwoOption: {
        slidesPerView: 1,
        observer: true, // 修改swiper自己或子元素时,自动初始化swiper
        observeParents: true, // 修改swiper的父元素时,自动初始化swiper
        centeredSlides: true,
        loop: true,
        effect: "coverflow",
        coverflowEffect: {
          rotate: 10, //滑动时旋转角度
          stretch: 206, //聚合宽度
          depth: 200, //景深
          modifier: 1, //覆盖叠加层数
          slideShadows: false, //是否阴影
        },
      },
      arr: [
        "https://t7.baidu.com/it/u=2942499027,2479446682&fm=193&f=GIF",
        "https://t7.baidu.com/it/u=3165657288,4248157545&fm=193&f=GIF",
        "https://t7.baidu.com/it/u=3240224891,3518615655&fm=193&f=GIF",
        "https://t7.baidu.com/it/u=2501476447,3743798074&fm=193&f=GIF",
      ],
    };
  },
};
</script>

<style>
.swiperTwoBox {
  margin: 0 1rem;
}
.swiperTwoBox img {
  width: 12.4rem;
  height: 6.775rem;
  display: block;
  margin: 0 auto;
}
</style>
  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值