Complete the code to import a component lazily in Vue.
const LazyComponent = [1](() => import('./LazyComponent.vue'))
Vue uses defineAsyncComponent to lazily load components.
Complete the code to register a lazy loaded component in the components option.
export default {
components: {
LazyComp: [1]
}
}You register the lazy loaded component by its variable name, here LazyComponent.
Fix the error in the lazy loading import syntax.
const LazyComp = defineAsyncComponent(() => [1]('./LazyComp.vue'))
Dynamic import uses the import function to load modules asynchronously.
Fill both blanks to create a lazy loaded component with a loading message.
const LazyComp = defineAsyncComponent({
loader: () => import('./LazyComp.vue'),
[1]: () => 'Loading...',
[2]: 200
})The loadingComponent option shows a component/message while loading, and delay sets how long to wait before showing it.
Fill all three blanks to create a lazy loaded component with error handling and timeout.
const LazyComp = defineAsyncComponent({
loader: () => import('./LazyComp.vue'),
[1]: () => import('./Loading.vue'),
[2]: () => import('./Error.vue'),
[3]: 3000
})loadingComponent shows a component while loading, errorComponent shows on error, and timeout sets max wait time.