I am completely new to working with Vue and I've been attempting to utilize $refs to retrieve some elements within the DOM from a sibling component. My objective is very basic, as I just need to obtain their heights, but I haven't had much success so far despite my efforts. I have been trying to do this within a computed property.
Regardless of what methods I use, this.$root.$refs
consistently turns out to be either undefined or an empty object. I'm at a loss as to where I may be going wrong.
In the parent component, my setup looks like this:
<template>
<ComponentA />
<ComponentB />
</template>
Within Component A, my code is structured as follows:
<template>
<div id="user-nav">
<div ref="nav-container">
<slot />
</div>
</div>
</template>
My approach has simply been to try accessing this in Component B by using console.log
console.log(this.$root.$refs);
within the mounted function of that particular component.
However, all I get is an empty object returned every time.
Is it not possible to access elements across sibling components in this manner???