because the data parameters given by the background are different from those needed by the front end, the data given by the background is as follows (with multiple layers of nesting):
code: null
id: 1
name: ""
parentId: null
sort: null
type: null
child: [{
code: "eos-admin-store-control"
id: 3
name: "eos"
parentId: 1
sort: null
type: null,
child: [{
code: "eos-admin-store-list"
id: 4
name: "eos"
parentId: 3
sort: null
type: null,
child: []
},
{
code: "eos-admin-store-list"
id: 5
name: "eos11111111"
parentId: 3
sort: null
type: null,
child: []
}
]
}]
how to replace it iteratively with recursion? Because recursion affects performance.
traverse the corresponding parameters according to the plug-in requirements. The format of the parameters is as follows:
fromData:[
{
id: "1",
pid: 0,
label: " 1",
children: [
{
id: "1-1",
pid: "1",
label: " 1-1",
children: []
},
{
id: "1-2",
pid: "1",
label: " 1-2",
children: [
{
id: "1-2-1",
pid: "1-2",
children: [],
label: " 1-2-1"
},
{
id: "1-2-2",
pid: "1-2",
children: [],
label: " 1-2-2"
}
]
},
{
id: "2-1",
pid: "1",
label: " 1-2",
children: [
{
id: "2-2-1",
pid: "2-1",
children: [],
label: " 1-2-1"
},
{
id: "2-2-2",
pid: "2-1",
children: [],
label: " 1-2-2"
}
]
}
]
},
]