两个嵌套的foreach中如何在一个foreach中拿到另一个foreach中遍历出来的内容


this.SelectFolderOptions.forEach( item => {
          console.log(item, 'item');
          item.folderList.forEach( each => {
            console.log(each.id, 'each');
          })
        })
        this.setSelectFolderOptions.forEach( Item => {
        Item.children.forEach( Each => {
          console.log(Each,'Each');
        })
      })

我想在下面这个Each 中加入上面的 each.id 类似这样{id:1 name:xiaoming age:12}应该如何操作呢,谢谢

大概就是这个思路https://blog.csdn.net/qq_42556623/article/details/120543441


  get() {
      let sf = [
        {
          id: 234,
          text: "wt"
        },
        {
          id: 234,
          text: "wt"
        },
        {
          id: 234,
          text: "wt"
        }
      ];
      let sds=[{
          id: 234,
          text: "wt",
          naem:"23"
        },
        {
          id: 234,
          text: "wt",
          naem:"23"
        },
        {
          id: 234,
          text: "wt",
          naem:"23"
        }];
        let ste=[]
        sf.forEach(item=>{
          sds.forEach((item,index)=>{
            ste.push({
                naem:item.naem,
                id:item.id
            })
        })
        })
       
        console.log(ste);
        
    }

img