美文网首页Vue
vue中的列表过度

vue中的列表过度

作者: 程序员同行者 | 来源:发表于2018-07-25 13:13 被阅读19次
    <!DOCTYPE html>
    <html>
    <head>
        <title>vue中的列表过度</title>
        <script src="./vue.js"></script>
        <style>
            .v-enter,.v-leave-to {
                opacity: 0;
            }
            .v-enter-active,.v-leave-active {
                transition: opacity: 3s;
            }
        </style>
    </head>
    <body>
    <div id='app'>
        <transition-group>
        <div v-for="item of list" :key="item.id">
            {{item.title}}
        </div>
        </transition-group>
        <button @click="handleBtn">Add</button>
    </div>
    <script>
        var count = 0; 
        var vm1 =  new Vue({
            el: '#app',
            data: {
                list: [],
            },
            methods: {
                handleBtn: function() {
                    this.list.push(
                    {
                        id: count ++,
                        title: "hello world"
                            }
                        )
                }
            }
        
            
        })
        
    </script>
    </body>
    </html>
    

    相关文章

      网友评论

        本文标题:vue中的列表过度

        本文链接:https://www.haomeiwen.com/subject/saxsmftx.html