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

useRequestEvent

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

Nuxt 環境 中,您可以使用 useRequestEvent 來存取傳入的請求。

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

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