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 -->
|
<!-- some content -->
|
||||||
<NuxtErrorBoundary @error="someErrorLogger">
|
<NuxtErrorBoundary @error="someErrorLogger">
|
||||||
<!-- You use the default slot to render your content -->
|
<!-- You use the default slot to render your content -->
|
||||||
<template #error="{ error }">
|
<template #error="{ error, clearError }">
|
||||||
You can display the error locally here.
|
You can display the error locally here: {{ error }}
|
||||||
<button @click="error = null">
|
<button @click="clearError">
|
||||||
This will clear the error.
|
This will clear the error.
|
||||||
</button>
|
</button>
|
||||||
</template>
|
</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