vue中css动画原理

<!DOCTYPE html>
<html>
<head>
    <title>vue中css动画原理</title>
    <script src="./vue.js"></script>
    <style>
        /*// 显示动画过度*/
        .v-enter {
            opacity: 0;
        }
        .v-enter-active {
            transition: opacity 3s;
        }
        /*// 隐藏动画过度*/
        .v-leave-to {
            opacity: 0;
        }
        .v-leave-active {
            transition: opacity 3s;
        }
    </style>
</head>
<body>
<div id='app'>
    <transition>
    <div v-if="show" >hello world</div>
    </transition>
    <button @click='handleClick'>切换</button>
</div>
<script>
    
    var vm1 =  new Vue({
        el: '#app',
        data: {
            show: true
        },
        methods: {
            handleClick: function() {
                this.show = !this.show
            }
        }
    
        
    })
    
</script>
</body>
</html>

推荐阅读更多精彩内容