Last active
March 27, 2020 18:39
-
-
Save daliborgogic/b3955eab545a54f3fe345491bec82245 to your computer and use it in GitHub Desktop.
Dynamic Components
This file contains 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> | |
<form> | |
<Component v-for="({ type }, index) in schema" :key="index" :is="'v' + type" /> | |
</form> | |
</template> | |
<script> | |
export default { | |
components: { | |
vInput: () => import('@/components/form/Input' /* webpackChunkName: "components/form/Input" */), | |
vTextArea: () => import('@/components/form/TextArea' /* webpackChunkName: "components/form/TextArea" */), | |
// Not used, not loooooaded | |
vCheckBox: () => import('@/components/form/TextArea' /* webpackChunkName: "components/form/CheckBox" */) | |
// etc | |
}, | |
data: () => ({ | |
// Predefined or created/edited in CMS for example | |
schema: [ | |
{ | |
type: 'Input', | |
label: 'First name' | |
}, | |
{ | |
type: 'TextArea', | |
label: 'Message' | |
} | |
] | |
}) | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment