Comments (10)
The issue comes from vue-router and suspense - we need to ensure that within each suspense fork we have different route objects. We in fact even do custom handling within <template>
(injecting a custom route
object) and for useRoute
...
We probably need to port this fix to this.$route
as well, if possible.
from nuxt.js.
Just found out that this.$route
inside computed is getting triggered twice. Added console.log
there while debugging.
from nuxt.js.
I did something similar, but i got error thatthis
is undefined. But I did it with dynamic regex which supported both ctx
and this
cases. I'm going to try to handle just this.$route
case.
from nuxt.js.
Thanks for making the PR for me @jakubednar time saver! <3
from nuxt.js.
Start a new pull request in StackBlitz Codeflow.
from nuxt.js.
Hello 👋, I started working on this issue, but I got a little stuck. I didn't manage to make it work, but from investigation it looks like this.$route
inside computed is not waiting for page:finish
hook and it gets the new route object right away.
from nuxt.js.
@jakubednar This might help. It's how we ensure that we use the provided route rather than this.$route
:
nuxt/packages/nuxt/src/pages/plugins/route-injection.ts
Lines 17 to 27 in f209158
from nuxt.js.
I could create a Vue plugin and overwrite the $route
with the Nuxt provided route. What you think of this as potential fix? @danielroe
Doing a replace like you did will be hard for this case when using options API
from nuxt.js.
I tried fixing it yesterday, but all I managed to affect was useRoute
, $route
inside template. Maybe I'm doing something wrong, but I couldn't affect this.$route
inside script.
I will be grateful for any help with this.
from nuxt.js.
I tried fixing it yesterday, but all I managed to affect was
useRoute
,$route
inside template. Maybe I'm doing something wrong, but I couldn't affectthis.$route
inside script. I will be grateful for any help with this.
After further investigation, I think you can do something like this:
`js
const INJECTION_RE = /\bthis.$route\b/g
if (!INJECTION_SINGLE_RE.test(code) || code.includes('ctx..provides[__nuxt_route_symbol')) { return }
let replaced = false
const s = new MagicString(code)
s.replace(INJECTION_RE, () => {
replaced = true
return '(this._.provides[__nuxt_route_symbol] || this.$route)'
})
if (replaced) {
s.prepend('import { PageRouteSymbol as __nuxt_route_symbol } from '#app/components/injections';\n')
} `
Did this very fast but I think you get the general idea, do a replace for this.$route
too and inject the "nuxt route" and fallback to this.$route like daniel did for the _ctx case!
from nuxt.js.
Related Issues (20)
- Page scrolls to top after reloading page and then restores the scroll position" HOT 2
- routeRules doesn't work HOT 12
- Add ability to configure HMR port
- FOUC in Production since Nuxt 3.10.0
- navigateTo not working inside defineNuxtPlugin on initial render HOT 3
- Page navigation shows warning - Component is already mounted, please use $fetch instead
- "How to Set Server Cookie in Nuxt 2, Multiple Users Requesting at the Same Time is a Confusion Problem" HOT 4
- createError from server middleware does not use /error.vue HOT 3
- Zod Async Refine always returning false HOT 5
- Using `getCachedData` together with `await useLazyAsyncData` causing it to not be pending anymore
- pages:extend routes takes the same name route HOT 1
- [nightly] generate/prerender doesn't work anymore HOT 1
- Node 20 not supporting prepack script (Module Author) HOT 1
- Cannot read properties of undefined (reading 'appMiddleware') HOT 1
- await $fetch with layoutTransition and pageTransition mounted executed twice In a different layout HOT 1
- on cloudflare_module build, favicon.ico hasn't images HOT 1
- Can't define Expose be used after the request? HOT 3
- cors headers appear as fixed values. HOT 1
- I don't think this is a bug. no-cors only supports content-types of application/x-www-form-urlencoded, multipart/form-data or text/plain. HOT 5
- `useId` hydration mismatch when used in a dynamic global component HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nuxt.js.