前端实现模糊搜索
onSearchChange() {
if(this.keyword){
let text = this.keyword
let reg = new RegExp(text)
//利用正则规则获取符合搜索条件的数据
let list = this.newList.filter(item => reg.test(item.name))
//获取符合条件的数据
this.list=list
}else{
//keyword为空,则恢复全部数据显示
this.list = this.newList
}
},