代码
提交代码
<!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=edge"> <title>Document</title> <style> #app{ text-align: center; } .dialog{ width: 100px; height: 100px; border: 1px solid #333; margin: 60px auto; text-align: center; line-height: 100px; } .bounce-enter-active { animation: bounce-in 400ms; } .bounce-leave-active { animation: bounce-out 300ms; } @keyframes bounce-in { 0% { transform: scale(0.7); } 50% { transform: scale(1.3); } 100% { transform: scale(1); } } @keyframes bounce-out { 0% { transform: scale(1); } 100% { transform: scale(0.4); } } </style> </head> <body> <div id = "app"> <button v-on:click = "show = !show">{{ show ? '显示 Dialog' : '隐藏 Dialog'}}</button> <transition name = "bounce"> <p v-show = "show" class="dialog">Dialog...</p> </transition> </div> </body> <script src="https://unpkg.com/vue/dist/vue.js"></script> <script type = "text/javascript"> var vm = new Vue({ el: '#app', data: { show:false } }); </script> </html>
运行结果