我需要帮助才能从树上找到所有可能的组合
我阅读了很多有关笛卡尔积的文档,尝试了很多东西,但似乎都无法正常工作...
这是我的树
var data = [
{
"id": 5,"name": "Support papier","type": "filter","children": [
{
"id": 24,"name": "60 g/m² papier mat","type": "value","children": []
},{
"id": 7,"name": "90 g/m² papier couché","children": [
{
"id": 8,"name": "Propriété papier","children": [
{
"id": 18,"name": "Papier mat","children": [],},{
"id": 60,"name": "Papier brillant",}
]
}
],}
]
}
]
这是我的预期结果:
[
[
{id: 5,name:"support papier",type: "filter"},{id: 24,name:"60 g/m² papier mat",type: "value"},],[
{id: 5,{id: 7,name:"90 g/m² papier mat",{id: 8,name:"Propriété papier",{id: 18,name:"Papier mat",{id: 60,name:"Papier brillant",]
]
当然,每个空数组都可以填充...:)
感谢您的帮助:)