Vue中css动画原理

<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>Vue中css动画原理</title>
    <script src="https://cdn.jsdelivr.net/npm/vue@2.5.16/dist/vue.js"></script>
</head>
<style>
/*第一帧*/


/*默认v-*/

.v-enter,
.v-leave-to {
    opacity: 0;
}

.v-enter-active,
.v-leave-active {
    transition: opacity 3s;
}
</style>

<body>
    <div id="app">
        <transition>
            <div v-show='show'>hello world</div>
        </transition>
        <button @click="handleClick">切换</button>
    </div>
    <script>
    new Vue({
        el: "#app",
        data: {
            show: true
        },
        methods: {
            handleClick: function() {
                this.show = !this.show;
            }
        }
    })
    </script>
</body>

</html>

推荐阅读更多精彩内容