findAncestry(arr, id) {var temp = []
var forFn = function (list, id) {for (var i = 0; i < list.length; i++) {var item = list[i]
if (item.id === id) {temp.unshift(item.id)
forFn(arr, item.parentId)
break
} else {if (item.children) {forFn(item.children, id)
}
}
}
}
forFn(arr, id)
temp.unshift('0')
return temp
},
应用
console.log('aaaaaaaaa',this.findAncestry(this.menuOptions,this.form.pid))