• 根据A组数 筛选 B数组中的数据


    需求: 在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);
  • 相关阅读:
    《Apache Velocity用户指南》官方文档
    Mockito教程
    GitHub访问速度慢的解决方法
    使用log4jdbc记录SQL信息
    分环境部署SpringBoot日志logback-spring.xml
    SpringBoot入门之spring-boot-maven-plugin
    swagger报No operations defined in spec!
    delphi 时间
    DELPHI常用类型及定义单元
    delphi 多线程编程
  • 原文地址:https://www.cnblogs.com/a1-top/p/14049466.html
Copyright © 2020-2023  润新知