//utils.js
export const checkList = (list, code, path = []) => {
if (!list) return []
for (const data of list) {
path.push(data.value)
if (data.value == code) return path
if (data.children && data.children.length) {
const findchildren = checkList(data.children, code, path)
if (findchildren.length) return findchildren
}
path.pop()
}
return []
}
引入使用
import { checkList } from '../utils/utils.js'
let arr = checkList( list , code ).filter(Boolean)
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。