vue怎么实现重复动画
我做出了一次性的动效,没有办法在变回来循环使用,看了vue官方文档,没找到我想要的方法,
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style>
@keyframes one {
0% {
width: 100px;
background: red;
}
100% {
width: 0px;
background: red;
}
}
@keyframes two {
0% {
width: 100px;
background: red;
}
100% {
width: 100px;
background: red;
-webkit-transform: rotate(135deg);
}
}
@keyframes three {
0% {
width: 100px;
background: red;
}
100% {
width: 100px;
background: red;
transform: rotate(45deg) translate(-28px,-28px);
/* -webkit-transform-origin: center; */
/* -webkit-transform: translate(50px,100px); */
}
}
.line {
margin-top: 20px;
width: 100px;
height: 20px;
background: red;
color: #fff;
border-radius: 8px;
}
.box {
display: flex;
flex-direction: column;
width:100px;
}
.one {
animation: one 1s ease .1s forwards;
}
.two {
animation: two 1s ease .1s forwards;
}
.three {
animation: three 1s ease .1s forwards;
}
</style>
</head>
<body>
<div name="close" class="box" @click="change">
<div :class="line1"></div>
<div :class="line2"></div>
<div :class="line3"></div>
</div>
<script src="https://cdn.jsdelivr.net/npm/vue@2.5.16/dist/vue.js"></script>
<script>
new Vue({
el: '.box',
data: {
line1: 'line',
line2: 'line',
line3: 'line',
},
methods: {
change() {
this.line1 = 'line one';
this.line2 = 'line two';
this.line3 = 'line three';
}
}
})
</script>
</body>
</html>
怎么用
v-enter
v-enter-active
v-enter-to
v-leave
v-leave-active
v-leave-to
实现
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
用css动画实现,参考https://cn.vuejs.org/v2/guide...