<!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>