I'm trying to watch if a class exist in a dom element inside my component but can't figure out the way to do this inside the onMounted hook:
This a simplified version of my template:
<template>
<a
ref="tabLink"
href="#"
role="tab"
:class="{ chatUpdated: this.chatSessionId === tab.chatSessionId }"
>
{{ tab.title }}
</a>
</template>
This is my setup function:
setup() {
const tabLink = ref(null);
onMounted(() => {
console.log(tabLink.value["0"].classList[0]);
});
}
As you can see I'm trying to console.log the classes of my <a> tag in my template but I always get an undefined value. I thought that the component's DOM was already there when the onMounted hook is called so I don't get why I'm getting an undefined value.