docs(api): specify nuxt-error-boundary events and slots (#4159)

This commit is contained in:
Clément Ollivier 2022-04-07 15:26:36 +02:00 committed by GitHub
parent da82e23bad
commit 6205fbe316
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,7 +1,33 @@
# `<NuxtErrorBoundary>`
Nuxt provides the `<NuxtErrorBoundary>` component to handle client-side errors happening in its default slot, using Vue's [`onErrorCaptured` hook.](https://vuejs.org/api/composition-api-lifecycle.html#onerrorcaptured)
## Events
- **@error**: Event emitted when the default slot of the component throws an error.
```vue
<template>
<NuxtErrorBoundary @error="logSomeError">
<!-- ... -->
</NuxtErrorBoundary>
</template>
```
## Slots
- **#error**: Specify a fallback content to display in case of error.
```vue
<template>
<NuxtErrorBoundary>
<!-- ... -->
<template #error="{ error }">
<p>An error occured: {{ error }}</p>
</template>
</NuxtErrorBoundary>
</template>
```
::ReadMore{link="/guide/features/error-handling"}
::
::NeedContribution
::