Nuxt/examples/with-errors/components/FaultyComponent.vue
Daniel Roe 12304909bc
feat(nuxt3): add <NuxtErrorBoundary> component for fine-grained error handling (#3671)
* feat(nuxt3): add `<NuxtErrorBoundary>` component for fine-grained error handling

* feat: add `@error` event handling

* fix: don't clear error on nav

* fix: remove `clearError` wrapper

* fix: remove outdated implementation

* update clear error

* upddate example with FaultyComponent

Co-authored-by: Pooya Parsa <pyapar@gmail.com>
2022-03-16 16:49:53 +01:00

26 lines
464 B
Vue

<script setup>
const hasIssue = ref(true)
const fixIssue = (error) => {
hasIssue.value = false
error.value = null
}
</script>
<template>
<NuxtErrorBoundary>
<throw-error v-if="hasIssue" />
<div v-else>
Component is working ^_^
</div>
<template #error="{ error }">
Component failed to Render -_-
<button @click="fixIssue(error)">
(fix the issue)
</button>
</template>
</NuxtErrorBoundary>
</template>