<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.1/animate.min.css">
<style>
.v-enter-active,
.v-leave-active {
transition: opacity 3s;
}
.v-enter,
.v-leave-to {
opacity: 0;
}
</style>
<!DOCTYPE html>
<html lang="zh-CN">
<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>在Vue中同时使用过渡和动画</title>
<script src="./vue.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.1/animate.min.css">
<style>
.v-enter-active,
.v-leave-active {
transition: opacity 3s;
}
.v-enter,
.v-leave-to {
opacity: 0;
}
</style>
</head>
<body>
<div id="app">
<button @click="handleClick">Toggle</button>
<transition
type="transition"
appear
enter-active-class="animate__animated animate__swing v-enter-active"
leave-active-class="animate__animated animate__heartBeat v-leave-active"
appear-active-class="animate__animated animate__swing">
<div v-if="show">Dean😊💕</div>
</transition>
</div>
<script>
var vm = new Vue({
el: '#app',
data: {
show: true
},
methods: {
handleClick() {
this.show = !this.show
}
}
});
</script>
</body>
</html>