haiqiong
Results
1
comments of
haiqiong
function convert(list) { for(let i=list.length-1;i>=0;i--){ let pid =list[i].parentId; if(pid>0){ if(!list[pid-1].children){ list[pid-1].children=[]; } list[pid-1].children.push(list[i]) list.splice(i,1) } } console.log(list); }