<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<script src="https://unpkg.com/vue@next"></script>
<style>
@keyframes left2right {
0% {
transform: translate(0px);
}
25% {
transform: translate(-100px);
}
50% {
transform: translate(0px);
}
75% {
transform: translate(100px);
}
100% {
transform: translate(0px);
}
}
.animation {
animation: left2right 3s;
}
</style>
</head>
<body>
<div id="root"></div>
</body>
<script>
const app = Vue.createApp({
data() {
return {
hello: "hello world",
animate: {
animation: false,
},
};
},
world: "我是自定义的属性",
methods: {
handleClick() {
this.animate.animation = !this.animate.animation;
},
},
template: `
<h1 v-bind:class="animate" >{{hello}}</h1>
<div>{{$options.world}}</div>
<button v-on:click="handleClick" >点击切换</button>
`,
});
const vm = app.mount("#root");
</script>
</html>