Vue difference of refs and javascript method like getElementById

1k Views Asked by At

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?

1

There are 1 best solutions below

2
kissu On

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