两个树形结构数据如何取交集

新手上路,请多包涵

数据结构如下:

        const filterData = [
          {
            "authKey": "terminal",
            "children": [
              {
                "authKey": "manufacturer",
                "index": 2,
                "name": "厂商信息管理",
                "type": 1
              }
            ],
            "index": 5,
            "name": "终端管理",
            "type": 1
          },
          {
            "authKey": "receiveAccount",
            "children": null,
            "index": 0,
            "name": "收款账户管理",
            "type": 1
          }
        ]
        const route = [
          {
            path: '/account',
            name: 'account',
            redirect: '/account/receiveAccount',
            children: [
              {
                path: 'receiveAccount',
                component: () => import('@/views/account-manage/receive-account/receive-account.vue'),
                name: 'receiveAccount',
                meta: {
                  icon: 'receive-account',
                  title: '收款账户管理',
                  authKey: 'receiveAccount'
                }
              }
            ]
          },
          {
            path: '/terminal',
            name: 'terminal',
            redirect: '/terminal/terminalInfo',
            alwaysShow: true,
            meta: {
              icon: 'terminal',
              title: '终端管理',
              authKey: 'terminal'
            },
            children: [
              {
                path: 'terminalInfo',
                component: () => import('@/views/terminal-manage/terminal-info/terminal-info.vue'),
                name: 'terminalInfo',
                meta: {
                  title: '终端信息管理',
                  icon: 'terminal',
                  authKey: 'terminalInfo'
                }
              },
              {
                path: 'manufacturerInfo',
                component: () => import('@/views/terminal-manage/manufacturer-info/manufacturer-info.vue'),
                name: 'manufacturerInfo',
                meta: {
                  title: '厂商信息管理',
                  icon: 'manufacturer',
                  authKey: 'manufacturer'
                }
              }
            ]
          }
        ]

请问如何以filterData中的authkey为筛选条件,并且按照filterData的顺序结构,过滤出route中相匹配的数据(route中有符合条件的子数据,上级也保留)

阅读 3.5k
1 个回答
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题