mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-11 08:33:53 +00:00
feat(nuxt): add scoped helper for clearing error within boundary (#20508)
This commit is contained in:
parent
1444d89e3b
commit
e1e3d2cd8e
@ -156,9 +156,9 @@ If you navigate to another route, the error will be cleared automatically.
|
||||
<!-- some content -->
|
||||
<NuxtErrorBoundary @error="someErrorLogger">
|
||||
<!-- You use the default slot to render your content -->
|
||||
<template #error="{ error }">
|
||||
You can display the error locally here.
|
||||
<button @click="error = null">
|
||||
<template #error="{ error, clearError }">
|
||||
You can display the error locally here: {{ error }}
|
||||
<button @click="clearError">
|
||||
This will clear the error.
|
||||
</button>
|
||||
</template>
|
||||
|
@ -19,6 +19,10 @@ export default defineComponent({
|
||||
}
|
||||
})
|
||||
|
||||
return () => error.value ? slots.error?.({ error }) : slots.default?.()
|
||||
function clearError () {
|
||||
error.value = null
|
||||
}
|
||||
|
||||
return () => error.value ? slots.error?.({ error, clearError }) : slots.default?.()
|
||||
}
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user