js 递归遍历树形

 const getItem = function (tree, ID) {
    var Deep, T, F;
    for (F = tree.length; F;) {
        T = tree[--F]
        if (ID == T.id) return T;
        if (T.children) {
            Deep = getDepById(T.children, ID)
            if (Deep) return Deep
        }
    }
}

  

原文地址:https://www.cnblogs.com/wangyunhui/p/12599016.html