useRoute() in 'vue-router' is working but not in nuxt.
See original GitHub issueEnvironment
- Operating System:
Darwin
- Node Version:
v18.7.0
- Nuxt Version:
3.0.0-rc.8
- Package Manager:
yarn@1.22.19
- Builder:
vite
- User Config:
modules
,css
,colorMode
,vite
,app
- Runtime Modules:
nuxt-windicss@2.5.0
,@pinia/nuxt@0.3.1
,@nuxtjs/color-mode@3.1.4
,@nuxt/image-edge@1.0.0-27657146.da85542
- Build Modules:
-
Reproduction
https://stackblitz.com/edit/github-izskfd?file=components/Book.vue
Describe the bug
useRoute(), nuxt default provided function, has previous route information, and not updated on moving page.
But using import { useRoute } from vue-router
, resolve all problems.
Is there any point I missed?
Additional context
rc.6 doesn’t have problems but rc.8 has.
It just occurred as soon as updating from rc.6 to rc.8
Logs
No response
Issue Analytics
- State:
- Created a year ago
- Reactions:7
- Comments:14 (4 by maintainers)
Top Results From Across the Web
Route query is undefined when using useRoute() in setup() for ...
5 and I am experiencing an issue where useRoute() appears to retieve the route correctly but the query of the route is undefined,...
Read more >useRoute - Nuxt Composition API
In Vue 3, vue-router exports composition functions for accessing the current route and router. These helpers provide an equivalent whilst using Nuxt 2....
Read more >Vue Router and the Composition API
import { useRouter, useRoute } from 'vue-router' export default { setup() { const router = useRouter() const route = useRoute() function ...
Read more >Named Routes - Vue Router
Watch a free video lesson on Vue School. Alongside the path , you can provide a name to any route. This has the...
Read more >Dynamic Routing | Vue Router
route or route = useRoute() (inside a setup) router.replace(router. ... you should not call router.replace() but trigger a redirection by returning the new ......
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
Hi there ! Tiny ping because I’m also experiencing this issue. Nuxt version
3.0.0-rc.11
Code example:
For me too, the only way of making it work is to import manually
import { useRoute } from 'vue-router'
. When counting on the auto import it simply doesn’t work.PS: Note that the problem doesn’t come, at least in my case, from destructuring.
Thanks!
|@danielroe hi, in my application i am changing page with NuxtLink and i am using useRoute in footer. when first load the page useRoute data works very well but after i change page fullpath doesnt change. How can i fix this can anyone help me please?
“nuxt”: “3.0.0-rc.11”,