Last active
November 26, 2019 11:36
-
-
Save defiant/52fb605cf2cee80a2b0c8bf9aee8d0bc to your computer and use it in GitHub Desktop.
dynamic-component.vue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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