can not use router.push() in composable and utils directory
See original GitHub issueI tried to use useRouter() in composables directory and utils directory.
in composable directory
import { useRouter } from 'vue-router';
const router = useRouter()
export function navigateTo(url: string) {
router.push(url)
}
in utils directory
import { useRouter } from 'vue-router';
const router = useRouter()
export function navigateTo(url: string) {
router.push(url)
}
but it throws a undefined Error when I call navigateTo function in component 。
I create a mini repository here : https://github.com/weisiqian/nuxt3-app.git
_Originally posted by @weisiqian in https://github.com/nuxt/framework/discussions/1749#discussioncomment-1598478_
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
react router history.push not loading expected component
After login successful I want redirect user to dashboard so for that: yield call(forwardTo, '/dashboard') which execute forwardTo function and ...
Read more >How to change route in utils file #1749 - nuxt/framework - GitHub
I tried to use useRouter() in composables directory and utils directory. in composable directory. import { useRouter } from 'vue-router'; ...
Read more >useRouter · Nuxt Composables
TIP: router.addRoute() adds route details into an array of routes and it is useful while building Nuxt plugins while router.push() on the other...
Read more >next-type-safe-routes - npm
next-type-safe-routes parses the /pages folder in your Next.js app and generates types for all the pages and API routes in the application.
Read more >Compose UI - Android Developers
In UI tests using a Compose rule, continuations resumed during withFrameNanos callbacks will not be dispatched until after all frame callbacks have finished ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
thank you @danielroe