While working with the composition API in Vue 3, I am trying to create a reference to a component dynamically. Typically, this would involve adding ref="name"
to the template and then defining a ref using const name = ref(null)
. However, I am looking for a way to use dynamic ref names instead.
In the options API, a possible solution could be to use something like:
:ref="
name${x}"
and then access it in the code as: this.$refs[
name${x}]
.
Unfortunately, with the composition API, direct access to $refs is not available. Is there a way to achieve this without resorting to using a function inside the template ref?