举例:省市区级联。
1,深度优先遍历:一层往死里遍历。
//深度优先遍历:递归 function deefFor(tree) { console.log('深度', tree.val) tree.children.forEach(deefFor) //for接收一个回调函数,参数默认是item。 }
2,广度优先遍历:同层遍历。