Vue 列表过渡

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <script src="./vue.v2.6.10.dev.js"></script>
        <style>
            .v-enter, .v-leave-to {
                opacity: 0;
            }
            .v-enter-active, .v-leave-active {
                transition: opacity 1s;
            }
        </style>
    </head>
    <body>
        <div id="app">
            <transition-group>
                <div v-for="(item, index) of list" :key="item.id">
                    {{item.title}}
                </div>
            </transition-group>
            <button @click="handleBtnClick">添加</button>
        </div>
        
        <script>
            var count = 0
            
            var vm = new Vue({
                el: '#app',
                data: {
                    list: [],
                },
                methods: {
                    handleBtnClick: function() {
                        this.list.push({
                            id: count++,
                            title: 'hello world'
                        })
                    },
                }
            })
        </script>
    </body>
</html>
<transition-group>
    <div v-for="(item, index) of list" :key="item.id">
        {{item.title}}
    </div>
</transition-group>

相当于

<transition>
    <div></div>
</transition>
<transition>
    <div></div>
</transition>
<transition>
    <div></div>
</transition>
<transition>
    <div></div>
</transition>