Home  >  Q&A  >  body text

How to get the vnode of a DOM element in Vue 3.0

As shown in the topic. How to get the vnode by accessing the DOM via document.getElementById(id)?

P粉377412096P粉377412096207 days ago417

reply all(1)I'll reply

  • P粉745412116

    P粉7454121162024-03-27 09:55:24

    I think mapping dom to virtual dom is not a good idea. But if you know what you're doing, then go ahead. You can scan the virtual dom from the root directory and check where each vnode is installed to find the virtual node you are interested in.

    There is some information about virtual dom scanning. The author of this article matched component types, but you can match vnode.el.

    reply
    0
  • Cancelreply