hasParentByName

Check if given component has a parent with given name.

API

function hasParentByName(
    vm: ComponentPublicInstance | undefined | null,
    name: string,
): boolean;
  • vm - Component instance.
  • name - The name of the parent to be found.

Usage

Given the following markup:

<my-root-component>
    ...
    <my-parent-component>
        ...
        <my-child-component></my-child-component>
    </my-parent-component>
</my-root-component>

And given this is the MyChildComponent instance:

hasParentByName(this, "MyChildComponent"); // --> true
hasParentByName(this, "MyParentComponent"); // --> true
hasParentByName(this, "NowhereToBeFound"); // --> false

Esc för att stänga Pil upp/ner för att navigera Enter för att välja