UNPKG

nuxt

Version:

Nuxt is a free and open-source framework with an intuitive and extendable way to create type-safe, performant and production-grade full-stack web applications and websites with Vue.js.

26 lines (25 loc) 746 B
import { defineComponent, onErrorCaptured, ref } from "vue"; import { useNuxtApp } from "../nuxt.js"; export default defineComponent({ emits: { error(_error) { return true; } }, setup(_props, { slots, emit }) { const error = ref(null); const nuxtApp = useNuxtApp(); onErrorCaptured((err, target, info) => { if (import.meta.client && (!nuxtApp.isHydrating || !nuxtApp.payload.serverRendered)) { emit("error", err); nuxtApp.hooks.callHook("vue:error", err, target, info); error.value = err; return false; } }); function clearError() { error.value = null; } return () => error.value ? slots.error?.({ error, clearError }) : slots.default?.(); } });