<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="../css/animate.css"/>
<title>Vue Css动画</title>
<script src="../js/vue.js"></script>
</head>
<style>
/* @keyframes bounce-in{
0%{
transform: scale(0);
}
50%{
transform: scale(1.5);
}
100%{
transform: scale(1);
}
}
.fade-enter-active{
transform-origin: left center;
animation: 1s;
}
.fade-leave-active{
transform-origin: left center;
animation: bounce-in 1s reverse;
} */
/* 过渡动画 */
.fade-enter ,.fade-leave-to{
opacity: 0;
}
.fade-leave-active,.fade-enter-active{
transition: opacity 3s;
}
</style>
<body>
<div id="app">
<!-- appear解决第一次无动画 type设置动画时常基准 :duration设置动画时长-->
<transition
type="transition"
name="fade"
:duration="{enter:5000,leave:10000}"
appear
enter-active-class="animated swing fade-enter-active"
leave-active-class="animated shake fade-leave-active"
appear-active-class="animated swing fade-enter-active"
>
<div v-show="show">Hello world</div>
</transition>
<button @click="handleClick">切换</button>
</div>
</body>
<script>
var vm = new Vue({
el:"#app",
data:{
show:true
},
methods:{
handleClick(){
this.show = !this.show;
}
}
})
</script>
</html>