reducePageDataTree = (result: any) => { return result.map((item: any) => { if(item.children.length) { item.children = this.reducePageDataTree(item.children) // 把子元素的遍历结果传递给item.children中 } return {...item, key: item.id} // 把修改后的item返回 }) };