拿到一个新需求 就是在前端进行查询一个数据
(虽然一般这种行为都是在后端进行但是有时候就是会给你这个需求,这里因为数据量较小所以就进行简单的遍历查询 没有对数据进行排序后查询 其实有想过二分查找之类的 但是这里数据量较小 就遍历吧)
search() {
console.log(this.searchInformation)
this.listData = []
var str = ".*" + this.searchInformation + ".*"
let reg = new RegExp(str)
//这里通过邀请码查询
for(var i=0;i<this.wholeListData.length;i++){
if(reg.test(this.wholeListData[i].content)){
this.listData.push(this.wholeListData[i])
}
}
//通过附加信息查询
for(var i=0;i<this.wholeListData.length;i++){
if(reg.test(this.wholeListData[i].addition)){
this.listData.push(this.wholeListData[i])
}
}
},