Home > Blockchain >  Using Suspense component in vue 3 along with Options API
Using Suspense component in vue 3 along with Options API

Time:03-07

The docs https://vuejs.org/guide/built-ins/suspense.html#async-components says in order to use Suspense Components, we need to make the components "Asynchronous".

<script setup>
const res = await fetch(...)
const posts = await res.json()
</script>

<template>
  {{ posts }}
</template>

But I am not sure how to make components Async using Options API.

CodePudding user response:

With the Options API, the component is made an async component by using an async setup():

export default {
               
  • Related