HTML/Html-Vue/Vue-动画.html
2023-05-01 19:37:40 +08:00

67 lines
1.2 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
@keyframes leftToRight {
0% {
transform: translateX(-100px);
}
50% {
transform: translateX(-50px);
}
0% {
transform: translateX(0px);
}
}
.animation {
animation: leftToRight 3s;
}
</style>
<title>Document</title>
<script src="https://unpkg.com/vue@next"></script>
</head>
<body>
<div id="root"></div>
<script>
//过度 ,动画
const app = Vue.createApp({
data(){
return {
animate:{
animation:false
}
}
},
methods:{
handleClick(){
this.animate.animation=!this.animate.animation
}
},
template: `
<div>
<div :class="animate">hello Vue</div>
<button @click="handleClick">切换</button>
</div>
`
});
const vm = app.mount('#root');
</script>
</body>
</html>