在调取接口获取的列表里的所有对象,对象里的某个字段名有不符合的就去掉

在调取接口获取的列表里的所有对象,显示对象里的某个字段名,如果这个字段后边的内容包含不符合条件的信息,就要不显示这个对象。

代码如下,两次遍历

/** 查询预警列表 */
    getNewsList() {
      this.loading = true;
      serve.get('/yqxx/listYqxx',{
        params:{
          pageSize: 10,
          pageNum: this.pageNum,
          created: '2021-09-01 00:00:00',
          order: 'DESC'
        }
      }).then(res => {
        let newArr = []
        let list = res.data.data
        list.forEach(item => {
          for(let val of this.cityList){
            if(item.doc_TITLE.indexOf(val) != -1){
              newArr.push(item)
              break
            }
          }
        })
        this.newsList = this.newsList.concat(newArr);
        console.log(this.newsList,'41563546524');
        this.total = this.newsList.length
        this.loading = false;

      })
    }
  }