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

0

Hello, I have a simple list where I do not use v-for. I would like to know if it is possible to identify the list item through #ref in vue.js; I usually identify my components with name and Id, however 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 would like to know how to do it by ref.

Thank you

    
asked by anonymous 07.12.2016 / 19:29

1 answer

1

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

Using ref in the component with v-for the name given in the reference is 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 it is possible to use id and name (not .vue, that of component itself) on them, all properties can be used, and it will be added in the component's root element, but generally id you set overlaps that of the component, but rarely does a component use id .

    
16.01.2017 / 12:04