javascript - How to query or delete a node in a tree structure by id in js
欧阳克
欧阳克 2017-07-05 11:05:50
0
1
1177

Ant design requires this kind of data structure to form various tree controls. This is really not as good as ztree and the like. People only need one array. After specifying the id and parentId, the tree will automatically appear. antd also I need to get children, I don’t think it’s any good

For example, the tree structure is like this

[ { id: '1', name: 'a', pid: '0', children: [ { id: '11', name: 'a-1', pid: '1', children: [ id: '111', name: 'a-1-1', pid: '11', children: null ] } ] }, { id: '2', name: 'b', pid: '0', children: null, } ]

So if we can quickly find the node with id: '111', can we only use recursive query? Is there a better way?
Perform the following operations on it:
Add child nodes: that is, in his children Add
to delete the node: that is, delete the node with id: '111'
Update node

欧阳克
欧阳克

温故而知新,可以为师矣。 博客:www.ouyangke.com

reply all (1)
三叔

Add a conversion layer and use id as the index for the reconstructed data

    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!