showError
Nuxt 提供了一种快速简便的方法,可以根据需要显示全屏错误页面。
在 Nuxt 上下文 中,你可以使用 showError
显示错误。
¥Within the Nuxt context you can use showError
to show an error.
参数:
¥Parameters:
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) 的共享错误状态。
¥The error is set in the state using useError()
to create a reactive and SSR-friendly shared error state across components.
showError
调用 app:error
钩子。