透過 100 多個技巧的集合學習 Nuxt!

useRequestEvent

使用 useRequestEvent composable 存取傳入的請求事件。

Nuxt 上下文中,您可以使用 useRequestEvent 來存取傳入的請求。

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

// Get the URL
const url = event?.path
在瀏覽器中,useRequestEvent 將回傳 undefined