<html>
<head>
<meta charset="utf-8" />
<title>Vue中同时使用过渡和动效</title>
<script src="./vue.js"></script>
<link rel="stylesheet" type="text/css" href="./animate.css">
<style>
.fade-enter, .fade-leave-to {
opacity: 0
}
.fade-enter-active, .fade-leave-active {
transition: opacity 5s;
}
</style>
</head>
<body>
<div id="root">
<!--type设定时长的参照标准type="transition"--:duration直接规定动画秒数:duration="5000"-->
<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 shake">
<div v-if="show">hello world</div>
</transition>
<button @click="handleClick">切换</button>
</div>
<script>
var vm = new Vue({
el: "#root",
data: {
show: true
},
methods: {
handleClick: function () {
this.show = !this.show
}
}
})
</script>
</body>
</html>
网友评论