0๐
I wrote a small recursive function for you which any of the children component can call which goes through the hierarchy of parent to find the parent with certain attribute and return that attribute value to caller. You just need to add additional checks to prevent any deadman loops.
export function findParentAttrValue(parent: any, attr: string): string {
if (parent[`${attr}`]) {
return parent[`${attr}`];
} else {
return findParentAttrValue(parent.$parent, attr);
}
}
- [Vuejs]-Method Not Allowed on API Search
- [Vuejs]-Is correct use vuejs with cshtml and a js (without webpack)
Source:stackexchange.com