REFS和JavaScript方法(如GetElementById)的VUE差异
我知道两者都可以让我访问一个元素,但是有什么区别?
REFS更容易访问元素是差异的?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
前提这种用法的好处是您留在Vuejs的反应性领域。因此,您不会混合Vue和Vanilla JS。
然后,AFAIK模板ref在VUE3中具有反应性,因此它将带来更大的好处,因为对于特定DOM操作的任何更新(与Vanilla JS相对),您将需要更少来回。
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).