引入css
<link href="./css/Animate.css" rel="stylesheet">
使用transition标签控制区域
bounceIn 、bounceOut为相关动作animated 固定写法,可以加到
<p v-if="flag" class="animated">{{msg}}</p>
<transition enter-active-class="animated bounceIn" leave-active-class="animated bounceOut" :duration="{enter:200,leave:200 }"
>
<!--需求:点击按钮,让p显示,再点击,让p隐藏-->
<p v-if="flag">{{msg}}</p>
</transition>
案例代码
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<!--//导入js包-->
<script src="js/vue.js"></script>
<!-- Bootstrap -->
<link href="./bootstrap/dist/css/bootstrap.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/vue-resource@1.5.1"></script>
<link href="./css/Animate.css" rel="stylesheet">
</head>
<body>
<div id="app">
<input type="button" value="戳我进入" @click="flag=!flag">
<!--模板网站:https://daneden.github.io/animate.css/-->
<!--duration表示进出场时间,可以分别设置和独立设计-->
<transition enter-active-class="animated bounceIn" leave-active-class="animated bounceOut" :duration="{enter:200,leave:200 }"
>
<!--需求:点击按钮,让p显示,再点击,让p隐藏-->
<p v-if="flag">{{msg}}</p>
</transition>
</div>
<script type="text/javascript">
new Vue({
el: '#app',
data: {
msg: 'hellfo vue.js.',
flag: false
}
});
</script>
</body>
</html>