Nâng CaoVue.js iconVue.js

Suspense component là gì?

<Suspense> cho phép render fallback content trong khi async component đang resolve — xử lý async setup():

vue
<Suspense>
  <template #default>
    <AsyncDashboard />  <!-- async setup() -->
  </template>
  <template #fallback>
    <LoadingSpinner />
  </template>
</Suspense>

AsyncDashboard có thể có async setup() với await bên trong. <Suspense> catch async và show fallback cho đến khi resolve.

  • Tích hợp với <KeepAlive> và lazy components.

Pitfall: Một số edge case (nhiều async deps, nested Suspense với SSR) có thể behave không như kỳ vọng — test kỹ.

Xem toàn bộ Vue.js cùng filter theo level & chủ đề con.

Mở danh sách Vue.js