<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
#box{
width: 100px;
height: 100px;
background-color: red;
}
.animate{
animation: myanimate 2s infinite alternate;
/*infinite是不断的做*/
}
@keyframes myanimate{
0%{
transform:translate(0);
}
50%{
transform:translate(20px);
}
100%{
transform:translate(0);
}
}
</style>
</head>
<body>
<div id="app">
<div id="box" :class="{ animate:isUseAnimate }"></div>
<button @click="isUseAnimate=!isUseAnimate">开始/结束</button>
</div>
</body>
<script src="https://unpkg.com/vue@next"></script>
<script>
const app=Vue.createApp({
data(){
return {
msg:"father",
isUseAnimate:false
}
},
components:{
},
methods:{
change(){
}
}
});
app.mount("#app");
</script>
</html>
vue3之自定义动画代码
最新推荐文章于 2024-01-29 09:25:01 发布