function findParents(treeData, id) {
let breadcrumbArray = []
var findele = (data, id) => {
data.forEach((item, index) => {
if (item.id === id) {
breadcrumbArray.unshift(item.name)
//breadcrumb += item.name + " >&nbidsp; "
findele(treeData, item.pId)
}
})
}
findele(treeData, id)
return breadcrumbArray.join(" >  ")
}
function findParents(treeData, url) {
let treeNode = "";
treeData.forEach((item, index) => {
if (item.u === url) {
treeNode = item;
}
})
if ("" === treeNode) {
return
}
let id = treeNode.id;
let breadcrumbArray = []
var findele = (data, id) => {
data.forEach((item, index) => {
if (item.id === id) {
breadcrumbArray.unshift(item.name)
//breadcrumb += item.name + " >  "
findele(treeData, item.pId)
}
})
}
findele(treeData, id)
return breadcrumbArray.join(" >  ")
}
|