<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>vue</title>
<script src="https://cdn.jsdelivr.net/npm/vue@2.5.16/dist/vue.js">
</script>
<style>
</style>
</head>
<body>
<h1>多个实例</h1>
<div id="app-one">
<input v-model="text" type="text">
<!-- <button v-on:click="handleClick()">add</button> -->
<ul>
<li v-for="(data,index) in processDatalis" :key="data">
{{data}}</li>
</ul>
</div>
</body>
</html>
<script>
var vm = new Vue({
el: "#app-one",
data:{
text:"",
datalist:["sdfs","wewef","vdfvwe","123","53454"]
},
methods:{
handleClick(){
this.datalist.push(this.text);
}
},
computed:{
processDatalis(){
return this.datalist.filter((item,index)=>item.indexOf(this.text)>-1);
}
}
});
</script>
网友评论