es6 递归 tree

function loop(data) {
let office = data.map(item => {

if(item.type == '1' ||item.type == '2') {
item = {...item,disabled:true,children:loop(item.children)}
return item
}else {
return item
}

})
return office
}
let officeDataTree = loop(officeData)

  

posted @ 2017-06-27 17:25  年少的你如此美丽  阅读(791)  评论(0编辑  收藏  举报