0
0
Vueframework~5 mins

Suspense for async components in Vue

Choose your learning style9 modes available
Introduction

Suspense helps show a loading message while waiting for a component to load. It makes the app feel faster and smoother.

When loading a component that fetches data from the internet.
When a component takes time to load because it is large or complex.
When you want to show a spinner or message while waiting for a part of the page.
When you want to improve user experience by avoiding blank screens during loading.
Syntax
Vue
<Suspense>
  <template #default>
    <AsyncComponent />
  </template>
  <template #fallback>
    <div>Loading...</div>
  </template>
</Suspense>
Use to wrap the async component you want to load.
The