nuxt logo

文档翻译(非官方)

useRequestEvent

使用 useRequestEvent 组合式访问传入的请求事件。

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

// 获取底层请求事件
const event = useRequestEvent()

// 获取 URL
const url = event?.path

在浏览器中,useRequestEvent 将返回 undefined