使用filter实现内容匹配搜索
/*自己在写vue代码时,处理输入内容显示对应信息的功能*/
filterBy(search) {
return this.contentList.filter(data => { //contentList是一个内容数组,search参数为Input输入的value
return data.article_title.match(search) //通过match进行匹配,无结果返回contentList,有结果返回新数组
})
}