<input type="text" v-model="search" :value="search" @input="messagesearch" placeholder="请输入商品名称" placeholder-class="color:#4a4a4a" />
export default {
date () {
return {
shamlist:[ ] ,
search:'',
list:[
{
id: '856',
image:'../../../static/img/timg.jpg',
title:'爽脆时蔬2-1',
sales_volume:46,
price:'13.00',
surplus: 8,//当剩余里面有数字的时候,表示,剩余库存为多少8.
// surplus:'仅剩9份',
storage:true,
tabScroll:0
},{
id: '856',
image:'../../../static/img/timg.jpg',
title:'爽脆时蔬2-1',
sales_volume:46,
price:'13.00',
surplus: 8,//当剩余里面有数字的时候,表示,剩余库存为多少8.
// surplus:'仅剩9份',
storage:true,
tabScroll:0
},
.............
]
}
},
methods:{
this.shamlist = this.list;
this.list= [ ];
// 遍历
for(var i = 0; i<this.shamlist.length; i++){
// 每一项的 title 值 与 this.search(value值) 作比较
if(this.shamlist[i].title.indexOf(this.search) != -1){
this.list.push(this.shamlist[i]);
}
}
}
}