Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/guide/extras/web-components.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,20 @@ defineCustomElement(MyComponent, {
})
```

To use a [Vue plugin](/guide/reusability/plugins) in a custom element, install it on the element's app instance inside `configureApp`:

```js
import MyPlugin from './my-plugin'

defineCustomElement(MyComponent, {
configureApp(app) {
app.use(MyPlugin)
}
})
```

Each custom element instance has its own Vue app, so plugins must be installed through `configureApp` for each instance that needs them.

### SFC as Custom Element {#sfc-as-custom-element}

`defineCustomElement` also works with Vue Single-File Components (SFCs). However, with the default tooling setup, the `<style>` inside the SFCs will still be extracted and merged into a single CSS file during production build. When using an SFC as a custom element, it is often desirable to inject the `<style>` tags into the custom element's shadow root instead.
Expand Down