vue 3 suspense
<template>
<div v-if="error">
{{ error }}
</div>
<Suspense v-else>
<template #default>
<UserProfile />
</template>
<template #fallback>
<div>Loading...</div>
</template>
</Suspense>
</template>
<script>
import { onErrorCaptured } from 'vue'
setup () {
const error = ref(null)
onErrorCaptured(e => {
error.value = e
return true
})}
return { error }
</script>