<input type="text" placeholder="搜索" v-model="filterinput" class="form-control">
return {
msg: 'Welcome to Your Vue.js App',
customers:[],
alert:"",
filterinput:""
}
/*触发一个方法,第一个只是数组,第二个是输入的值,对比数组和输入的是否匹配*/
<tr v-for="(customer,index) in filterby(customers,filterinput)">
<th scope="row">{{customer.name}}</th>
<td>{{customer.phone}}</td>
<td>{{customer.tel}}</td>
<td>{{customer.email}}</td>
<td>{{customer.id}}</td>
<td><router-link v-bind:to="'/customerdetail/'+customer.id">详情</router-link></td>
</tr>
filterby(customers,value){
/*遍历数组*/
return customers.filter(function(customer){
return customer.name.match(value)
})
}