今天小编给大家分享一下如何使用Vue组件实现旋转木马动画的相关知识点,内容详细,逻辑清晰,相信大部分人都还太了解这方面的知识,所以分享这篇文章给大家参考一下,希望大家阅读完这篇文章后有所收获,下面我们一起来了解一下吧。

10年积累的成都做网站、网站设计经验,可以快速应对客户对网站的新想法和需求。提供各种问题对应的解决方案。让选择我们的客户得到更好、更有力的网络服务。我虽然不认识你,你也不认识我。但先网站策划后付款的网站建设流程,更有铁东免费网站建设让你可以放心的选择与我们合作。
源码如下
js:
export default {
data() {
return {
piclist: [
{ url: require("../image/pic1.png") },
{ url: require("../image/pic2.png") },
{ url: require("../image/pic3.png") }
],
//文件图片配置
config: [
{
position: "absolute",
width: "400px",
top: "20px",
left: "50px",
opacity: 0.2,
zIndex: 2,
transition: "1s"
},
{
position: "absolute",
width: "800px",
top: "100px",
left: "200px",
opacity: 1,
zIndex: 4,
transition: "1s"
},
{
position: "absolute",
width: "400px",
top: "20px",
left: "750px",
opacity: 0.2,
zIndex: 2,
transition: "1s"
}
],
previous: 0,
now: Date.now()
};
},
methods: {
//实现点击按钮切换的动画,设置时间参数防止多次点击
turnleft: function() {
this.now = Date.now();
if (this.now - this.previous > 1000) {
this.config.push(this.config.shift());
this.previous = this.now;
}
},
turnright: function() {
this.now = Date.now();
if (this.now - this.previous > 1000) {
this.config.unshift(this.config.pop());
this.previous = this.now;
}
}
}
};css:
* {
margin: 0;
padding: 0;
}
#wrapper {
margin: auto;
height: 500px;
width: 79%;
position: relative;
}
ul {
list-style: none;
}
li img {
height: 500px;
width: 100%;
}
.prev,
.next {
position: absolute;
height: 60px;
width: 60px;
border-radius: 50%;
top: 50%;
margin-top: -56px;
overflow: hidden;
text-decoration: none;
background-color: aqua;
z-index: 5;
opacity: 1;
}
.prev {
left: 0;
}
.next {
right: 0;
}
.picleft {
width: 400;
top: 20;
left: 50;
opacity: 0.2;
z-index: 2;
}
.piccenter {
width: 800;
top: 100;
left: 200;
opacity: 1;
z-index: 4;
}
.picright {
width: 400;
top: 20;
left: 750;
opacity: 0.2;
z-index: 2;
}以上就是“如何使用Vue组件实现旋转木马动画”这篇文章的所有内容,感谢各位的阅读!相信大家阅读完这篇文章都有很大的收获,小编每天都会为大家更新不同的知识,如果还想学习更多的知识,请关注创新互联行业资讯频道。