我需要帮助才能从树中找到所有组合的可能性
我阅读了很多关于笛卡尔积的文档,尝试了很多东西,但它们似乎都不能正常工作......
这是我的树
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é",
"type": "value",
"children": [
{
"id": 8,
"name": "Propriété papier",
"type": "filter",
"children": [
{
"id": 18,
"name": "Papier mat",
"type": "value",
"children": [],
},
{
"id": 60,
"name": "Papier brillant",
"type": "value",
"children": [],
}
]
}
],
}
]
}
]
这是我的预期结果:
[
[
{id: 5, name:"support papier", type: "filter"},
{id: 24, name:"60 g/m² papier mat", type: "value"},
],
[
{id: 5, name:"support papier", type: "filter"},
{id: 7, name:"90 g/m² papier mat", type: "value"},
{id: 8, name:"Propriété papier", type: "filter"},
{id: 18, name:"Papier mat", type: "value"},
],
[
{id: 5, name:"support papier", type: "filter"},
{id: 7, name:"90 g/m² papier mat", type: "value"},
{id: 8, name:"Propriété papier", type: "filter"},
{id: 60, name:"Papier brillant", type: "value"},
]
]
当然,可以填充每个空数组... :)
谢谢你的帮助:)