Skip to content

Instantly share code, notes, and snippets.

@fadamakis
Created January 30, 2021 13:11
Show Gist options
  • Save fadamakis/8307754a64d5df29c40ea3c4c85bb7e3 to your computer and use it in GitHub Desktop.
Save fadamakis/8307754a64d5df29c40ea3c4c85bb7e3 to your computer and use it in GitHub Desktop.
Handling Loading State - Long format
const AsyncComponent = () => ({
// The component to load (should be a Promise)
component: import('./MyComponent.vue'),
// A component to use while the async component is loading
loading: LoadingComponent,
// A component to use if the load fails
error: ErrorComponent,
// Delay before showing the loading component. Default: 200ms.
delay: 200,
// The error component will be displayed if a timeout is
// provided and exceeded. Default: Infinity.
timeout: 3000
})
@rizkhal
Copy link

rizkhal commented Feb 23, 2021

currently the component property updated as loader

@fadamakis
Copy link
Author

currently the component property updated as loader

Thanks @rizkhal That's one of the changes in Vue 3 that also uses defineAsyncComponent helper. But this is based on Vue 2 docs.

@rizkhal
Copy link

rizkhal commented Feb 23, 2021

Thanks @fadamakis, this is my fault for skipping a few lines in your article

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment