setTree(data) { const tree = []; data.forEach(item => { const children = this.list.filter(e => e.parentId === item.id) if(children.length) { item.children = children this.setTree(item.children) } if(!item.parentId){ tree.push(item) } }) tree.sort((a, b) => {a.order - b.order}) return tree; }
标签:const,树结构,tree,list,item,children From: https://www.cnblogs.com/fdxjava/p/17221701.html