Complete the code to wrap the async component with Suspense.
<template>
<Suspense>
<[1] />
<template #fallback>
<p>Loading...</p>
</template>
</Suspense>
</template>The async component must be placed inside the Suspense tag to enable fallback content while loading.
Complete the code to define an async component using Vue's defineAsyncComponent.
<script setup> import { defineAsyncComponent } from 'vue' const AsyncComponent = defineAsyncComponent(() => import('./MyComponent.vue')) const componentName = '[1]' </script>
The variable holding the async component is AsyncComponent, which you use in the template.
Fix the error in the Suspense fallback slot syntax.
<template>
<Suspense>
<AsyncComponent />
<template [1]>
<p>Loading...</p>
</template>
</Suspense>
</template>The correct syntax for the fallback slot in Vue Suspense is <template #fallback>.
Fill both blanks to create a Suspense with a timeout and error component.
<template> <Suspense :timeout=[1]> <AsyncComponent /> <template #fallback> <LoadingSpinner /> </template> <template #[2]> <ErrorMessage /> </template> </Suspense> </template>
The timeout prop expects a number in milliseconds (e.g., 3000). The error slot is named error to show error content.
Fill all three blanks to create a dictionary comprehension filtering async components by load time.
<script setup>
const components = {
compA: defineAsyncComponent(() => import('./CompA.vue')),
compB: defineAsyncComponent(() => import('./CompB.vue')),
compC: defineAsyncComponent(() => import('./CompC.vue'))
}
const fastComponents = Object.entries(components).reduce((acc, [[1], comp]) => {
if (comp.loadTime [2] 1000) acc[[3]] = comp
return acc
}, {})
</script>When using Object.entries, the first element is the key (here named 'key'). We check if comp.loadTime < 1000 and assign to acc[key].