Nuxt3 中文课程 《实战全栈开发简书》.

useRequestEvent

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

在你的页面、组件和插件中,你可以使用 useRequestEvent 来访问传入的请求。

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

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