SOURCE

const path = [
    {
        id:4,path:'1/2/3/4'
    },
    {
        id:4,path:'1/2/3/5'
    }
]

let tree = [
  {
    child:[
        {
            child:[
                {
                    child:[
                        {
                            child:null,
                            name:'子4',
                            id:4
                        },
                        {
                            child:null,
                            name:'子5',
                            id:5
                        },
                        {
                            child:null,
                            name:'子6',
                            id:6
                        },
                        {
                            child:null,
                            name:'子7',
                            id:7
                        }
                    ],
                    name:'子3',
                    id:3
                }
            ],
            name:'子2',
            id:2
        }
    ],
    name:'子1',
    id:1
  }
]

const selectedCheck = (node,_path)=>{
    _path.forEach((pathItem)=>{
        if(pathItem.id == node.id){
            node.status = pathItem.status;
        }
        if(pathItem.child){
            selectedCheck(node,pathItem.child)
        }
    })
}

const deep = (_tree)=>{
    _tree.forEach((item)=>{
        //item.prentNode = prentNode;
        selectedCheck(item,path)
        if(item.child){
            deep(item.child)
        }
    })
}

deep(tree)
console.log(tree)
console 命令行工具 X clear

                    
>
console