vue-3D轮播图-无插件

效果

3d轮播图

代码

<template>
  <div class="center_contion">
    <div class="wrapper">
      <div class="box" ref="box">
        <div class="ball ball_1" @click="start" :class="this.index==0?'active':''">
          <img class="icon" src="../../../../assets/images/home1/card_icon01.png" />
          <p>资金集中度</p>
          <p class="data">86%</p>
        </div>
        <div class="ball ball_2" :class="this.index==1?'active':''">
          <img class="icon" src="../../../../assets/images/home1/card_icon02.png" />
          <p>集中结算率</p>
          <p class="data">86%</p>
        </div>
        <div class="ball ball_3" :class="this.index==2?'active':''">
          <img class="icon" src="../../../../assets/images/home1/card_icon03.png" />
          <p>账户监控率</p>
          <p class="data">86%</p>
        </div>
      </div>
    </div>

  </div>
</template>

<script>
export default {
  name: "centerContion",
  data() {
    return {
      timer: "",
      timeShow: false,
      x: 0,
      index: 0,
      timer1: null,
    };
  },
  methods: {
    //滚动函数
    roll() {
      let box = this.$refs["box"];
      this.x = this.x - 120;
      this.index = this.index == 2 ? 0 : this.index + 1;
      // this.x = this.x == 2 ? -180 : this.index * 180;

      box.style.transform = "rotateX(-8deg) rotateY(" + this.x + "deg)";
    },
    onVisibilityChange() {
      if (!document[hiddenProperty]) {
        timer = setInterval(roll, 2000);
      } else {
        clearInterval(timer);
      }
    },
    getTime() {
      this.timeShow = !this.timeShow;
    },
    //点击图片滚动
    start() {
      clearInterval(timer);
      roll();
      setTimeout(function () {
        clearInterval(timer);
        timer = setInterval(roll, 2000);
      }, 2000);
    },
  },
  mounted() {
    //  this.timer = setInterval(this.getTime, 10000);
    this.timer = setInterval(this.roll, 4000);
  },
  beforeDestroy() {
    this.onVisibilityChange();
    clearInterval(this.timer);
  },
};
</script>

<style scoped lang='less'>
* {
  margin: 0;
  padding: 0;
  list-style: none;
}
.center_contion {
  width: 60%;
  height: 65%;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  top: 7%;
  background-image: url("../../../../assets/images/home1/car_bottom.png");
  background-size: 100% 100%;
  display: flex;
  justify-content: center;
}
* {
  margin: 0;
  padding: 0;
}
.wrapper {
  margin-top: 16%;
  perspective: 3000px;
  perspective-origin: 599px 146px;
}
.box {
  width: 450px;
  transform: rotateY(0deg) rotateX(-8deg);
  transform-style: preserve-3d;
  transition-duration: 1s;
  margin: 0 auto;
}
.ball:nth-child(1) {
  transform: rotateY(0deg) translateZ(400px);
}
.ball:nth-child(2) {
  transform: rotateY(120deg) translateZ(400px);
}
.ball:nth-child(3) {
  transform: rotateY(240deg) translateZ(400px);
}
.ball {
  width: 300px;
  height: 300px;
  text-align: center;
  position: absolute;
  cursor: pointer;
  background-size: 100% 100%;
  color: rgba(255, 255, 255, 0);
  overflow: hidden;
  color: #fff;
  background-image: url("../../../../assets/images/home1/card.png");
  p {
    text-align: center;
    font-size: 26px;
    font-family: SourceHanSansCN;
    font-weight: bold;
    color: #fff;
  }
  .data {
    color: #ec9a00;
  }
  .icon {
    width: 75px;
    height: 75px;
    margin-top: 40px;
  }
}
.active {
  width: 450px;
  height: 450px;
  p {
    text-align: center;
    font-size: 46px;
    font-weight: bold;
    color: #fff;
    text-indent: 10px;
  }
  .icon {
    width: 86px;
    height: 86px;
    margin-left: 6px;
  }
  .data {
    color: #ec9a00;
    // text-indent: 20px;
    padding-left: 10px;
  }
}
</style>

  • 2
    点赞
  • 15
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
vue-awesome-swiper是一个Vue.js轮播图插件,可以实现立体环绕的效果。您可以通过安装vue-awesome-swiper,然后在Vue实例中引入并使用它来创建立体环绕的轮播图。具体的安装和使用步骤如下: 1. 首先,您需要使用npm或yarn安装vue-awesome-swiper插件。您可以运行以下命令来安装它: ``` npm install vue-awesome-swiper --save ``` 2. 安装完成后,在您的Vue组件中引入vue-awesome-swiper插件: ``` import Vue from 'vue'; import 'swiper/css/swiper.css'; import VueAwesomeSwiper from 'vue-awesome-swiper'; Vue.use(VueAwesomeSwiper); ``` 3. 在模板中使用vue-awesome-swiper来创建立体环绕的轮播图。您可以在模板中使用`<swiper>`标签,并使用`<swiper-slide>`标签作为轮播图的每个项。例如: ``` <swiper> <swiper-slide>Slide 1</swiper-slide> <swiper-slide>Slide 2</swiper-slide> <swiper-slide>Slide 3</swiper-slide> </swiper> ``` 4. 您可以在Vue组件的选项中设置一些配置来实现立体环绕的效果。例如,您可以设置`effect`属性为`'cube'`来实现立方体翻转效果: ``` <swiper :effect="'cube'"> ... </swiper> ``` 总结起来,您可以通过安装vue-awesome-swiper插件,并在Vue组件中引入并使用它来创建立体环绕的轮播图。具体的安装和使用步骤请参考引用和引用中提供的相关资料。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [基于vue.js轮播组件vue-awesome-swiper实现轮播图](https://download.csdn.net/download/weixin_38556205/13239506)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"] - *2* [使用Vue-Awesome-Swiper实现旋转叠加轮播效果&平移轮播效果](https://download.csdn.net/download/weixin_38736760/12938108)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"] - *3* [vue轮播图插件vue-awesome-swiper](https://download.csdn.net/download/weixin_38727087/13201307)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"] [ .reference_list ]

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值