showError
Nuxt 提供了一种快速简单的方法来在需要时显示全屏错误页面。
在Nuxt 上下文中,您可以使用showError
来显示错误。
参数
error
:string | Error | Partial<{ cause, data, message, name, stack, statusCode, statusMessage }>
showError('😱 Oh no, an error has been thrown.')
showError({
statusCode: 404,
statusMessage: 'Page Not Found',
})
错误通过useError()
在状态中设置,以在组件之间创建响应式且 SSR 友好的共享错误状态。
showError
会调用app:error
钩子。