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?

2
  • You mean template refs, right? Commented Jun 28, 2022 at 11:43
  • yes I meant template refs Commented Jun 29, 2022 at 0:16

1 Answer 1

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).

Sign up to request clarification or add additional context in comments.

2 Comments

what is the exact thing about you said 'updates to specific DOM manipulations'?
@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...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.