use ref in a list without v-for Vue.js

Asked

Viewed 211 times

0

Hello, I have a simple list in which I do not use v-for. I wonder if it is possible to identify the list item through the #ref in Vue.js; I usually identify my components with name and Id, but I am using a third party component which I do not have access to these properties. I need to get the index of the list item and I would like to know how to do this by the ref.

Grateful

1 answer

1


Yes, it is possible.
When not using the v-for, to ref becomes a common variable and can be rescued with this.$refs.suaref.

Using the ref in the component with the v-for the name given in the reference if makes an array of components, using this.$refs.suaref[indice] it is possible to work with the referenced component.

Obs: Even with third party components you can use id and name(not that of . Vue, the same component) on them, all properties can be used, and it will be added in the root element of the component, but usually the id that you define overrides that of the component, but rarely who makes a component use the id.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.