Skip to content

Instantly share code, notes, and snippets.

@defiant
Last active November 26, 2019 11:36
Show Gist options
  • Save defiant/52fb605cf2cee80a2b0c8bf9aee8d0bc to your computer and use it in GitHub Desktop.
Save defiant/52fb605cf2cee80a2b0c8bf9aee8d0bc to your computer and use it in GitHub Desktop.
dynamic-component.vue
<template>
<div class="card">
<component v-bind:is="componentFile"></component>
</div>
</template>
<script>
export default{
props: {
componentName: {
type: String,
required: true
}
}
computed: {
componentFile() {
return () => import(`./widgets/${this.componentName}.vue`);
}
}
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment