大佬我想看看你一面的第10题输出节点那个是怎么写的... 我自己写了个感觉不太好 function printPath(el, maxValue = el.getAttribute('data-v'), res = []) {     if (!el) return     let count = el.childElementCount     res.push(el.nodeName)     console.log(`[${res.toString()}, ${maxValue} ]`)     if (count > 0) {         let children = el.children         for (let i = 0; i < count; i++) {             curRes = [...res]             let cur = children[i].getAttribute('data-v')             maxValue = maxValue > cur ? maxValue : cur             printPath(children[i], maxValue, curRes)         }     } }
点赞 21

相关推荐

牛客网
牛客网在线编程
牛客网题解
牛客企业服务