3

I know both can make me to access to a element but what is the difference?
It is only difference that Refs is more easier to access the element?

kkokki
  • 51
  • 1
  • 4

1 Answers1

3

Assuming that you're speaking about template refs, the main benefit of such usage is that you stay in VueJS' reactivity realm. Hence, you don't mix Vue and vanilla JS.

Then, AFAIK template refs are reactive in Vue3, so it will bring even more benefit because you will need less back and forth regarding any updates to specific DOM manipulations (as opposing to vanilla JS).

kissu
  • 40,416
  • 14
  • 65
  • 133
  • what is the exact thing about you said 'updates to specific DOM manipulations'? – kkokki Jun 29 '22 at 00:14
  • @kkokki I don't know what you would like to do in your case. But for example, if you get a specific `input` tag (for some reason, even if `v-model` exists) and you check it's value, it will be reactive when the value will change. On the opposite, if you select something with a query selector, you will need to select it again if you want to have the updated value or if you have a computed based on it etc... – kissu Jun 29 '22 at 00:42