I'm trying to dynamically include a template snippet from another file into my SFC template, but where I'd like the markup to appear I only get [Object Promise]. I understand this is because import(…) returns a Promise, but I can't for the life of me figure out how to resolve it. I've tried simply putting it in the template and I've tried resolving it in a function (import(…).then((t) => t)). Doesn't make any difference. Minimal example follows.
@/components/DynamicTemplateImport.vue:
<template>
<div>
<div
v-for="(filename, idx) of templates"
v-bind:key="idx"
>
{{ import(`@/templates/${filename}.vue`) }}
</div>
</div>
</template>
<script lang="ts">
import { Component, Vue } from 'vue-property-decorator';
@Component
export default class DynamicTemplateImport extends Vue {
templates = ['Foo', 'Bar', 'Baz'];
}
</script>
@/templates/Foo.vue:
<template>
<p>Foo</p>
</template>