本地模糊查询数组数据

fillterData(text, data, types) {
    let _text = text.toLowerCase();
    let result = [];
    result = data.filter(function(item) {
      var str = '';
      for (var i = 0; i < types.length; i++) {
        var _type = types[i];
        str += (item[_type] && item[_type].toLowerCase()) || '';
      }
      return str.toLowerCase().indexOf(_text.toLowerCase()) > -1;
    });
    return result;
  },
let functype=that.data.functype;
let jobtype=that.data.jobtype;
let jobarea=that.data.jobarea;
let result=[];

if(functype || jobarea || jobtype){
   let tempData1 = that.fillterData(functype, _data, [ 'functype' ]);
   let tempData2 = that.fillterData(jobarea, tempData1, [ 'jobarea' ]);
   result = that.fillterData(jobtype, tempData2, [ 'jobtype' ]);
}else{
   result=_data;
}
原文地址:https://www.cnblogs.com/qianduanjingying/p/13808649.html