GongWei_
听听那晚风
2021-01-20 17:58

将对象数组a中不包含数组b里的元素的项去除

  • vue.js
  • javascript
var a = [
        { name: "aa", children: [{ name: "aa1" }, { name: "aa2" }] },
        { name: "bb", children: [{ name: "bb1" }, { name: "bb2" }] },
        { name: "cc", children: [{ name: "cc1" }, { name: "cc2" }] },
        { name: "dd", children: [{ name: "dd1" }, { name: "dd2" }] },
        { name: "ee", children: [{ name: "ee1" }, { name: "ee2" }] },
      ];
var b = ["aa1","aa2","cc1", "bb2","dd1" ];
//目标对象
var mune = [
        { name: "aa", children: [{ name: "aa1" },{ name: "aa2" }] },
        { name: "bb", children: [{ name: "bb2" }] },
        { name: "cc", children: [{ name: "cc1" }] },
        { name: "dd", children: [{ name: "dd1" }] },
      ];

 

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

2条回答