vue_23 vue 列表过渡

2018-11-08  本文已影响0人  basicGeek
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>列表过渡</title>
    <script src="./vue.js"></script>
    <style>
        .v-enter,.v-leave-to{
            opacity: 0;
        }
        .v-enter-active,.v-leave-active{
            transition: opacity 1s;
        }
    </style>
</head>
<body>


<div id="root"> 
    <transition-group>
    <div v-for="item of list" :key="item.id">{{item.title}}</div>
    </transition-group>
    <button @click="handleclick">add </button>
</div>

<script>

    var count = 0;
    var vm = new Vue({
        el:"#root",
        data:{
            list:[]
        },
        methods:{
            handleclick:function(){
                this.list.push({
                    id:count++,
                    title:'hello world'
                })

            }
        }
    })
</script>

    
</body>
</html>
vue列表过渡vue列表过渡
上一篇 下一篇

猜你喜欢

热点阅读