1、树形数据为:
2、方法
let result=[]//结果数组 let treeToList=(treeArr)=>{ treeArr.forEach(treeitem=>{ result.push({ id: treeitem.id, label: treeitem.label }) if(treeitem['children']){ treeToList(treeitem['children']) } }) } treeToList(this.arr) console.log("生成list了没??",result)
3、结果
标签:result,list,树形,treeToList,------,treeitem From: https://www.cnblogs.com/zhaoyingzhen/p/16963038.html