需求是找到对应code第一次出现的位置,一下函数始终不能正确执行,大家帮忙改正下letmenus=[{code:2,name:'222',children:[{code:33,name:'222sa',children:[{code:44,name:'22'}]}]},{code:922,name:'922',children:[{code:9222,name:'92222222dsadsa',children:[{code:44222,name:'442222dsads'}]}]}]functiondigui(arr,code){for(vari=0;iif(arr[i].code==code){ returnarr[i]}else{if(arr[i].children){digui(arr[i].children,code)}}}}console.log(digui(menus,44222))
慕盖茨4494581
尚方宝剑之说
相关分类