Now there is a demand. It needs to be assembled into a tree node, that is, the parent-child node, based on the data requested by the server. The data structure after the server request is as shown below. Topology is an object, and the key under the object is a parent, value is the child array.
For example, 1 in the picture above has a child which is an array ["2"], and the child with value 2 has 4 children, that is, ["29", "39", "38", "37 "]
Finally, the following data structure needs to be generated, that is, the key is the string of parent, and because there are multiple children, it is an array
const data = ["1":["2":["29":["24":["27":["26"]]],"39":["47"],"38":["43":["45"]],"37":["42":["46"]]]]]
Thank you again.
Result:
The data you want to generate should be in this form:
@cool_zjy Thank you.
Yes, I need your data structure. I didn’t make it clear in the problem description, sorry.
Now this recursive data needs to be stuffed into the treenode of antd, that is, each parent needs to be composed of children into a Treenode, such as this (for example, the children nodes are not all written out).
This is an official document. The following code is my implementation (refer to the asynchronous data loading code in the official document), but an error is reported.
https://ant.design/components...