vuejs / router

🚦 The official router for Vue.js

Home Page:https://router.vuejs.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

with vue3.4 + router4 or above useRoute() or useRouter() will return undefined

jesseice opened this issue · comments

Reproduction

empty

Steps to reproduce the bug

const route = useRoute();
route // undefined

Expected behavior

return the current routing information

Actual behavior

return undefined

Additional information

No response

useRoute() must be used within script setup. It's only undefined when called in the wrong places. BTW, use discussions or the discord chat to ask questions, thanks!