useRequestEvent

源代码
使用 useRequestEvent 组合式函数访问传入请求事件。

Nuxt 上下文 中,你可以使用 useRequestEvent 来访问传入的请求。

// Get underlying request event
const event = useRequestEvent()

// Get the URL
const url = event?.path
在浏览器中,useRequestEvent 将返回 undefined