mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-16 10:54:49 +00:00
25 lines
552 B
TypeScript
25 lines
552 B
TypeScript
import { defineComponent, ref, onErrorCaptured } from 'vue'
|
|
import { useNuxtApp } from '#app'
|
|
|
|
export default defineComponent({
|
|
emits: {
|
|
error (_error: unknown) {
|
|
return true
|
|
}
|
|
},
|
|
setup (_props, { slots, emit }) {
|
|
const error = ref(null)
|
|
const nuxtApp = useNuxtApp()
|
|
|
|
onErrorCaptured((err) => {
|
|
if (process.client && !nuxtApp.isHydrating) {
|
|
emit('error', err)
|
|
error.value = err
|
|
return false
|
|
}
|
|
})
|
|
|
|
return () => error.value ? slots.error?.({ error }) : slots.default?.()
|
|
}
|
|
})
|