setResponseStatus
setResponseStatus 用于设置响应的状态(以及可选的 statusText)。
Nuxt 提供了组合式函数和实用工具,以支持一流的服务端渲染。
setResponseStatus 用于设置响应的状态(以及可选的 statusText)。
setResponseStatus 只能在 Nuxt 上下文 中调用。const event = useRequestEvent()
// event will be undefined in the browser
if (event) {
// Set the status code to 404 for a custom 404 page
setResponseStatus(event, 404)
// Set the status message as well
setResponseStatus(event, 404, 'Page Not Found')
}
在浏览器中,
setResponseStatus 将不会产生任何效果。