30.动画-使用过度类名
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width,initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=adge"> <title>Document</title> <script src="vue.js"></script> <style> .v-enter,.v-leave-to{ opacity:0; transform:translateX(100px); } .v-enter-active,.v-leave-active{ transition:all 1s ease; } </style> </head> <body> <div id="app"> <input type="button" value="动画切换" @click="flag=!flag"> <transition> <p v-show="flag">我是一个动画效果</p> </transition> <!-- 1.把要实现动画的元素,使用transition元素包裹起来 --> <!-- 2.要实现动画的元素,必须使用v-if或v-show来进行控制 --> </div> </body> <script> //创建Vue实例,得到ViewModel var vm=new Vue({ el:"#app", data:{ flag:true }, methods:{} }); </script> </html>