When adding elements via pure js on Vue Single File Component, the added elements don't have v-id-xx attribute for scoped css.
How can I get THE component's v-id-hash value by pure js?
The scoped-style data ID is added to the component instance as:
this.$options._scopeId // returns something like 'data-v-763db97b'
This way you could add it as attribute using:
somElement.setAttribute(this.$options._scopeId, "");
Here's a CodeSandbox demo showing an example.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With