let arr = []; req.data.forEach((e,k1) => { let obj = {}; obj.value = e.content; obj.children = []; obj.expand = false; if (e.children) { e.children.forEach((e2,k2) => { let obj2 = {}; obj2.value = e2.content; obj2.children = []; obj2.expand = false; obj.children.push(obj2); if (e2.children) { e2.children.forEach((e3,k3) => { obj2.children.push({ value: e3.content }); }); } }); } arr.push(obj); });标签:11,obj2,obj,04,js,content,let,children,e2 From: https://www.cnblogs.com/iuniko/p/16856772.html