I'm trying to access a ref from a parent component which is defined in the child component. I've got a file where I call the parent component and inside of the component I call 2 child components like so:
<my-component>
<component-header></component-header>
<component-content></component-content>
</my-component>
Inside my-component I've got a <slot></slot> and no other html, but that is where I need to call a ref which is listed in the component-header. Here is my component-header file:
<template>
<div ref="mycomponentHeader">
<slot>
// Here some other html
</slot>
</div>
</template>
How will I be able to call the mycomponentHeader ref inside the my-component parent? I've tried calling the ref like this:
console.log(this.$parent.$refs.mycomponentHeader)
console.log(this.$refs.mycomponentHeader)
console.log(this.$refs)
console.log(this.$children.$refs.mycomponentHeader)
But these resulted in an undefined, an empty object and a cannot read properties of undefined (reading '$refs'). Any help would be appreciated!