Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code block to dynamically register a component #1900

Merged
merged 3 commits into from
Oct 5, 2019
Merged
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
29 changes: 29 additions & 0 deletions packages/docs/docs/guide/using-vue.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,35 @@ export default {
</script>
```

If your module `export default` a Vue component, you can register it dynamically:

```vue
<template>
<component v-if="dynamicComponent" :is="dynamicComponent"></component>
</template>

<script>
export default {
data() {
return {
dynamicComponent: null
}
},

mounted () {
import('./lib-that-access-window-on-import').then(module => {
this.dynamicComponent = module.default
})
}
}
</script>
```

**Also see:**

- [Vue.js > Dynamic Components](https://vuejs.org/v2/guide/components.html#Dynamic-Components)


## Templating

### Interpolation
Expand Down