<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>过渡动画</title>
</head>
<body>
    <div id="app" class="demo">
        <button v-on:click="add">Add</button>
        <button v-on:click="remove">Remove</button>
        <transition-group name="list" tag="p">
           <span v-for="item in items" v-bind:key="item" class="list-item">
                {{item}}
            </span>
        </transition-group>
    </div>

    <script src="../js/vue.js"></script>

    <script>

        let vm = new Vue({
            el:'#app',
            data:{
                items:[1,2,3,4,5,6,7,8,9],
                nextNum:10
            },
            methods:{
                randomIndex(){
                    return Math.floor(Math.random() * this.items.length);
                },
                add(){
                    this.items.splice(this.randomIndex(),0,this.nextNum);
                },
                remove(){
                    this.items.splice(this.randomIndex(),1);
                }
            }
        });
    </script>

    <style type="text/css">
        .list-item{
            display: inline-block;
            margin-right: 10px;

        }

        .list-enter-active,
        .list-leave-active{
            transition: all 1s;
        }

        .list-enter,
        .list-leave-to{
            opacity: 0;
            transform: translateY(30px);
        }
    </style>
</body>
</html>