keyfram和transition同时使用
2018-08-03 本文已影响1人
椰果粒
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>动态组件</title>
<script src="https://unpkg.com/vue@2.5.16/dist/vue.js"></script>
<link rel="stylesheet" href="./animate.css">
<style>
.fade-enter, .fade-leave-to{
opacity: 0;
}
.fade-enter-active, .fade-leave-active{
transition: opacity 3s;
}
</style>
</head>
<body>
<div id="app">
<!-- 自定义动画的名字
appear表示第一次就显示动画的效果
-->
<transition
:duration="{enter:5000, leave:2000}"
type="transition"
name="fade"
appear
enter-active-class="animated swing fade-enter-active"
leave-active-class="animated tada fade-leave-active"
appear-active-class="animated swing"
>
<div v-show="show">hello world</div>
</transition>
<button @click="handleChange">显示与隐藏</button>
</div>
<script>
var vm = new Vue({
el : "#app",
data : {
show : true
},
methods : {
handleChange : function(){
this.show = !this.show
}
}
})
</script>
</body>
</html>