setResponseStatus
setResponseStatus 設定響應的狀態碼(可選地還可設定狀態訊息)。
Nuxt 提供可組合函式和實用工具,用於一流的伺服器端渲染支援。
setResponseStatus
設定響應的狀態碼(可選地還可設定狀態訊息)。
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
不會產生任何效果。