Complete the code to define an async component using Vue's defineAsyncComponent.
import { defineAsyncComponent } from 'vue'; const AsyncComp = [1](() => import('./MyComponent.vue'));
Vue provides defineAsyncComponent to create async components for lazy loading.
Complete the code to register the async component in the components option.
export default {
components: {
AsyncComp: [1]
}
};When registering components, use the component variable name without parentheses.
Fix the error in the async component import syntax.
const AsyncComp = defineAsyncComponent(() => [1]('./MyComponent.vue'));
Dynamic import is used to lazy load components in Vue async components.
Fill both blanks to add a loading component and error component to the async component options.
const AsyncComp = defineAsyncComponent({
loader: () => import('./MyComponent.vue'),
loadingComponent: [1],
errorComponent: [2]
});You can specify components to show while loading or on error by setting loadingComponent and errorComponent.
Fill all three blanks to create an async component with delay, timeout, and custom error component.
const AsyncComp = defineAsyncComponent({
loader: () => import('./MyComponent.vue'),
delay: [1],
timeout: [2],
errorComponent: [3]
});Delay and timeout are numbers in milliseconds. The errorComponent is a Vue component to show on failure.