Vue · Senior · Question 34 of 75

How do you expose a Vue component as a native Custom Element?

const MyWidget = defineCustomElement(Widget);
customElements.define("my-widget", MyWidget);

Explanation

Styles are injected into the shadow root. Props map to attributes/properties and emitted events become CustomEvents. Useful for embeddable widgets.

Further reading

Problem with a question

Vue · Senior · question 34

Test yourself

Take the Vue · Senior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz