<script>
new Vue({
el: '#app',
data: {
keywork: '',
persion: [
{id:'001',name:'马冬梅',age:19,sex:'女'},
{id:'002',name:'夏洛特',age:20,sex:'男'},
{id:'003',name:'啊马云',age:21,sex:'男'},
{id:'004',name:'刘芳的',age:22,sex:'女'}
],
watch:{
keywork(val){
// filter 不会更改原数组
this.persion.filter((p)=>{
//return p.age > 19;
return p.name.indexOf(val) !== -1;
})
}
}
}
})
</script>
网友评论