Nuxt 3 已于 31 July 2026 结束生命周期
此版本将不再接收错误修复或安全补丁。 升级到 Nuxt 4 或获取 HeroDevs 提供的延长支持

useRequestEvent

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

Maschinelle Übersetzung ·0 % geprüft

在 Nuxt context 中,你可以使用 useRequestEvent 访问传入的请求。

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

// 获取 URL
const url = event?.path
在浏览器中,useRequestEvent 会返回 undefined。