Using the Vue.js 2 api-composition, you have a .ref attribute on the setupContext argument of setup(). As stated in many articles and in this thread : https://github.com/vuejs/composition-api/issues/226 it will NOT be available in vue.js 3, and you should declare attributes of the same name as the ref-ed element :
<div ref='name'/>
setup() {
return {
name : ref(null)
}
}
However, what about when you do not know the ref name at the setup() ?
Like this "minimum" example :
<div v-for="e in elements" @click="elements.push({name:Math.random(), content:Math.random()})">
<div :ref="e.name">e.content</div>
</div>
setup(){
return {
a_function_called_later(){
// I can use this.$refs but is there a more "vuejs3" way to do it ?
}
// ...???
}
}