js 一个数组包含另一个数组中的数据,找到后添加到一个数组中


 let result = [
    {
      children: [
        {
          function_id: "01860ce0-b8b4-314e-86b1-b467ef42d978", 
          name: "\u4efb\u52a1\u521b\u5efa"
        }, 
        {
          function_id: "7d7a3a2e-5eb0-3712-ab74-96ec968a47af", 
          name: "\u4efb\u52a1\u7f16\u8f91"
        }
      ], 
      icon: "task", 
      menu_id: "9629e4b7-18df-3562-80f5-ff4c48f4ed8a", 
      name: "\u4efb\u52a1\u7ba1\u7406", 
      path: "/task"
    }, 
    {
      children: [
        {
          function_id: "d8dcb47a-b183-39b8-b0c2-a295b9b4282e", 
          name: "\u544a\u8b66\u7ec4\u521b\u5efa"
        }, 
        {
          function_id: "2582a435-891f-300e-9898-e7081f134503", 
          name: "\u544a\u8b66\u7ec4\u7f16\u8f91"
        }, 
        {
          function_id: "f20a1c5a-5352-3e18-8a58-ca2a31489b06", 
          name: "\u544a\u8b66\u7ec4\u5217\u8868"
        }
      ], 
      icon: "alarm", 
      menu_id: "2c002de7-9671-3d16-ae81-e856eb034019", 
      name: "\u544a\u8b66\u7ec4\u7ba1\u7406", 
      path: "/alarm"
    }, 
    {
      children: [], 
      icon: "subscribe", 
      menu_id: "4bc48c17-a869-34ea-b824-ea858479c10f\r\n4bc48c17-a869-34ea-b824-ea858479c10f", 
      name: "\u8ba2\u9605\u7ba1\u7406", 
      path: "/subscribe"
    }, 
    {
      children: [], 
      icon: "developer", 
      menu_id: "f31f494d-27f0-31c5-ab75-a5253bb9fbe5\r\n", 
      name: "\u5f00\u53d1\u8005\u6a21\u5f0f", 
      path: "/developer"
    }, 
    {
      children: [], 
      icon: "team", 
      menu_id: "37126136-afeb-3d25-a247-5b6cf212569f\r\n37126136-afeb-3d25-a247-5b6cf212569f\r\ncfe20dae-4ef9-3a7e-a4e7-3552ddde3cae", 
      name: "\u56e2\u961f\u7ba1\u7406", 
      path: "/team"
    }
  ]
}
let function_ids = ['01860ce0-b8b4-314e-86b1-b467ef42d978']

看function_ids这里的数据是否在res中存在

result.map(item =>{
          item.checkedList = []
          item.checkAll = false
          item.children.forEach(itemChild =>{
            if(function_ids.includes(itemChild.function_id)){
              item.checkedList.push(itemChild.function_id)
            }
          })
      })

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值