需求: 在B中删除A中出现的景区

A数组:

  // 隐藏数据
  hideData = [
    '北阁佛灯',
    '笔架山宋窑旧址',
    '道韵楼',
    '凤凰塔',
    '凤翔峡旅游风景区',
    '富丽公园',
    '海阳儒学宫',
    '华厦博物馆',
    '黄埔军校分校李厝祠',
    '己略黄公祠',
    '开元寺',
    '龙湖古寨',
    '千果山',
    '饶宗颐学术馆',
    '石壁山风景区',
    '市博物馆',
    '外江梨园公所',
    '许驸马府',
    '幽峪逸林',
  ]
View Code

B数组:原始数据跟以下格式一样

    "data": [{
        "areaId": 116,
        "sceneryLevel": "其他",
        "longitude": 115.9958630000000,
        "latitude": 23.5810580000000,
        "areaName": "黄满磜瀑布群",
        "parentAreaId": 144,
        "subscriberCount": 1329,
        "rank": 1
    }, {
        "areaId": 120,
        "sceneryLevel": "其他",
        "longitude": 115.9019510000000,
        "latitude": 23.4959750000000,
        "areaName": "龙潭镇关山村",
        "parentAreaId": 144,
        "subscriberCount": 582,
        "rank": 2
    }, {
        "areaId": 119,
        "sceneryLevel": "其他",
        "longitude": 115.8277720000000,
        "latitude": 23.4210060000000,
        "areaName": "河婆街道三山国王祖庙",
        "parentAreaId": 144,
        "subscriberCount": 515,
        "rank": 3
    }, {
        "areaId": 112,
        "sceneryLevel": "4A",
        "longitude": 115.9968790000000,
        "latitude": 23.5813220000000,
        "areaName": "黄满寨瀑布旅游区",
        "parentAreaId": 144,
        "subscriberCount": 467,
        "rank": 4
    }, {
        "areaId": 115,
        "sceneryLevel": "其他",
        "longitude": 115.9332120000000,
        "latitude": 23.5521900000000,
        "areaName": "大北山森林公园",
        "parentAreaId": 144,
        "subscriberCount": 393,
        "rank": 5
    }]
View Code

方法一:

 1   let C = [];
 2 
 3       B.map(v => {
 4 
 5         if (this.A.indexOf(v['areaName']) <= -1) {
 6 
 7           hideList.push(v)
 8 
 9         }
10       })

 方法二:

B.filter(item=> A.indexOf(item.openId) > -1);

 

 posted on 2020-11-27 17:46  楼顶铁板烧  阅读(104)  评论(0编辑  收藏  举报