How does vue3 get the current page route instance in non-vue file? #1872
-
I want to develop a utility class. The tool class provides a method to return the current page routing instance. How to achieve? I saw a way to rely on store implementation. Is there any function that does not depend on third-party implementation? Why is useRouter limited to be used only on vue component pages? |
Beta Was this translation helpful? Give feedback.
Answered by
posva
Jul 24, 2023
Replies: 1 comment
-
useRouter, like other composables, depend on |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
posva
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
useRouter, like other composables, depend on
inject()
and thus can only be used withinsetup()
. If you are not doing SSR, you can just import therouter
instance