想了很久,但是还是没有相同,copy了一个在线地址,麻烦各位大佬帮忙看看
项目地址:https://codesandbox.io/s/serverless-butterfly-yzy4r2?file=/sr...
const getAdminIcon = (nodeList) => {
console.log('nodeList', nodeList)
let iconNode = null
for (let i = 0; i < nodeList.length; i++) {
let item = nodeList[i]
console.log('item', item)
let bool = item.classList && item.classList.contains('mdi-alpha-a-circle')
console.log('bool', bool)
if (bool) {
iconNode = item
break
}
if (item.childNodes.length === 0) {
continue
}
iconNode = getAdminIcon(item.childNodes)
}
return iconNode
}
你这个里面有递归调用,但是怎么能没有 return 呢?