[Vue基础实战]transition动画

参考代码:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>transition动画</title>
    <style>
        .v-enter,
        .v-leave-to{
            opacity: 0;
            transform: translateX(150px);
        }
        .v-enter-active,
        .v-leave-active{
            transition: all 0.8s ease;
        }
    </style>
</head>
<body>    
    <div id="app">
        <input type="button" value="隐藏/显示" @click="flag=!flag">
        <transition>
            <div v-if="flag">你见,或者不见我,我就在那里,不悲不喜.</div>
        </transition>                              
    </div>
    <script src="../js/vue.js"></script>
    <script>
        const app = new Vue({
            el: '#app',
            data: {
                flag:true     
            }           
        });
    </script>
</body>
</html>

 

posted @ 2021-01-15 09:14  dshow  阅读(96)  评论(0编辑  收藏  举报