karol-f / vue-custom-element

Vue Custom Element - Web Components' Custom Elements for Vue.js
https://karol-f.github.io/vue-custom-element/
MIT License
1.97k stars 187 forks source link

Get DOM Node of the Vue Custom Element #207

Closed LucasBerger closed 4 years ago

LucasBerger commented 4 years ago

Hey, This may be just a feature-request. I want to change the attributes of the Custom Element. Is it possible to get the DOM Node of the Vue Custom Element in the class definition to alter the attributes in the class itself?

karol-f commented 4 years ago

Hi, You can use connectedCallback in which this is DOM element of widget.

You can also do sth like

document​.​querySelector​(​'widget-vue'​)​.

or

document​.​querySelector​(​'widget-vue'​)​.​getVueInstance​(​).$root.$el

Regards.

LucasBerger commented 4 years ago

nice, thank you, the .getVueInstance()-part is especially interesting for me.