@jesvin-palatty and @yoduh (thank you), I've tried to expand on these answers using defineAsyncComponent
, the following does indeed work, but I wonder whether my approach would be considered good practice?
<script>
import IconError from '@/components/icons/IconError.vue';
import {defineAsyncComponent} from "vue";
function getIcon(key) {
return defineAsyncComponent({
loader: () => import(`@/components/icons/Icon${key}.vue`),
errorComponent: IconError,
timeout: 3000
})
};
</script>
<template>
<IconBase><component :is="getIcon(item.icon)"></component></IconBase>
</template>