在 Nuxt 上下文 中,您可以使用 showError 来显示错误。
参数
error: string | Error | Partial<{ cause, data, message, name, stack, status, statusText }>showError('😱 Oh no, an error has been thrown.')
showError({
status: 404,
statusText: 'Page Not Found',
})
错误是通过使用 useError() 设置在状态中的,以在组件之间创建反应式且对 SSR 友好的共享错误状态。
showError 会调用 app:error 钩子。