there is a multi-level array with a variable number of layers. If you want to type a keyword, you can traverse the entire array and then filter out the elements on the fuzzy match with name, while retaining its hierarchical structure.
do you have any good ideas for implementation?
//
var treeNodeList=[
{
"name": "A",
"children": [{
"name": "-1",
"children": [{
"name": "-1-1",
"children": [
{
"name": "-1-1-1",
"type": "true",
},
{
"name": "-1-1-3",
"type": "true",
}
]
}]
},
{
"name": "B",
"children": [{
"name": "-1",
"children": [{
"name": "-2-2",
"children": [
{
"name": "-2-2-2",
"type": "true",
},
{
"name": "-2-2-1",
"type": "true",
}
]
}]
},
{
"name": "C",
"children": [{
"name": "-1",
"children": [{
"name": "-3-1",
"children": [
{
"name": "-3-3-1",
"type": "true",
},
{
"name": "-3-3-2",
"type": "true",
}
]
}]
},
]
// 3
[
{
"name": "A",
"children": [{
"name": "-1",
"children": [{
"name": "-1-1",
"children": [
{
"name": "-1-1-3",
"type": "true",
}
]
}]
},
{
"name": "C",
"children": [{
"name": "-1",
"children": [{
"name": "-3-1",
"children": [
{
"name": "-3-3-1",
"type": "true",
},
{
"name": "-3-3-2",
"type": "true",
}
]
}]
},
]
// A
[
{
"name": "A",
"children": [{
"name": "-1",
"children": [{
"name": "-1-1",
"children": [
{
"name": "-1-1-1",
"type": "true",
},
{
"name": "-1-1-3",
"type": "true",
}
]
}]
}
]