Skip to content
算法
HTML
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
QQ截图20190718130532.jpg 结果截图 Jul 18, 2019
README.md 添加说明 Jul 18, 2019
myvue.html
rmLeftRight.html
数组转化为树状结构.html 使用map递归遍历树,去掉parentID Jul 18, 2019

README.md

algorithm

算法

请把该数据整理为树状结构, 该树每个节点的结构如下,

var data = [
    { parentId: 0, id: 1, value: '1' }, 
    { parentId: 3, id: 2, value: '2' },
    { parentId: 0, id: 3, value: '3' },
    { parentId: 1, id: 4, value: '4' }, 
    { parentId: 1, id: 5, value: '5' },
    { parentId: 11, id: 6, value: '6' },
    { parentId: 10, id: 7, value: '7' },
    { parentId: 10, id: 8, value: '8' },
    { parentId: 11, id: 9, value: '9' },
    { parentId: 11, id: 10, value: '10' },
    { parentId: 2, id: 11, value: '11' },
];
node = {
    children: [],
    id: id,
    value: value
}

结果截图

结果截图

You can’t perform that action at this time.