useError

useError 可组合项返回正在处理的全局 Nuxt 错误。

可组合项返回正在处理的全局 Nuxt 错误,该错误在客户端和服务器上均可用。

¥The composable returns the global Nuxt error that is being handled and it is available on both client and server.

const error = useError()

useError 在状态中设置错误,并在组件之间创建一个响应式且支持服务器端渲染的全局 Nuxt 错误。

¥useError sets an error in the state and creates a reactive as well as SSR-friendly global Nuxt error across components.

Nuxt 错误具有以下属性:

¥Nuxt errors have the following properties:

interface {
  //  HTTP response status code
  statusCode: number
  // HTTP response status message
  statusMessage: string
  // Error message
  message: string
}
Read more in Docs > Getting Started > Error Handling.