VUE多元素動畫

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8" />
        <title>使用第三方動畫_animate</title>
        <link rel="stylesheet" type="text/css" href="css/animate.css">
    </head>
    <style type="text/css">
        p{
            width: 100px;
            height: 100px;
            background-color: grey;
            margin: 20px auto;
        }
    </style>
    <script type="text/javascript" src="js/vue.js" ></script>
    <body>
        <div id="div1">
            <input type="text" v-model="name">
            <!-- 多元素要用transition-group -->
            <transition-group enter-active-class="animated fadeInLeft" leave-active-class="animated fadeOutRight">
                <p v-for="(v,k) in arr2" :key="k" v-show="flag">
                    {{v}}
                </p>
            </transition-group>
        </div>
    </body>
    <script>
        let vm = new Vue({
            el: "#div1",
            data: {
                flag: true,
                arr: ['tom','jack','mike','alice','mark','jhon'],
                name: ''
            },
            computed: {
                arr2:function(){
                    var temp = [];
                    this.arr.forEach(val => {
                        if (val.includes(this.name)) {
                            temp.push(val);
                        }
                    });
                    return temp;
                }
            }
        });
    </script>
</html>
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章