-
-
Notifications
You must be signed in to change notification settings - Fork 5.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Named route throws Cannot assign to read only property error #1381
Comments
By replacing this line https://github.com/vuejs/vue-router/blob/dev/dist/vue-router.esm.js#L1302 (source:
it no longer throws an error. I don't have enough time to trace it more deeply now (why is .path not writeable), but I hope this is at least good starting point. |
hey @fandaa can you simplify the example in a js fiddle, please: http://jsfiddle.net/posva/9r6xhqbp/ |
Hi @posva, I tried to simplify it at WebpackBin. If you uncomment line 20 at Also next thing, if you comment lines 20 (with name) and 47 (getMatched call) and append Thanks for your time. |
@posva jsfiddle code. |
Thanks, that's much better 🙂 |
When |
I had a similarly error ( [email protected] [email protected] ) with the following callstack:
router.onReady(() => {
// Add router hook for handling asyncData.
// Doing it after initial route is resolved so that we don't double-fetch
// the data that we already have. Using router.beforeResolve() so that all
// async components are resolved.
router.beforeResolve((to, from, next) => {
// https://github.com/vuejs/vue-router/issues/1381
const route = Object.assign({}, to);
const matched = router.getMatchedComponents(route)
const prevMatched = router.getMatchedComponents(from)
let diffed = false
const activated = matched.filter((c, i) => {
return diffed || (diffed = (prevMatched[i] !== c))
})
if (!activated.length) {
return next()
}
//bar.start()
Promise.all(activated.map(c => {
if (c.asyncData) {
return c.asyncData({ store, route: to })
}
})).then(() => {
//bar.finish()
next() // <<<<<<<<<<<<<<<<<< client-entry.js:62
}).catch(next)
}) |
I also meet the problem.@fandaa provide way can work. |
Version
2.5.2
Reproduction link
https://github.com/fandaa/vue-router-bug/commits/master
Steps to reproduce
npm i
andnpm run dev
http://localhost:8080/x
and click ongo to y
What is expected?
Browser navigated to route
/y
.What is actually happening?
Getting
TypeError: Cannot assign to read only property 'path' of object '#<Object>'
as error.You can try to start at
http://localhost:8080/y
and try to navigate to/x
by clicking on links withgo to x using
as a prefix.vue-router seems to not cooperate with [email protected], it works just fine within my project using [email protected].
The problem is only with named routes, you can try
http://localhost:8080/a
, where you can navigate to/b
and vice-versa without any difficulty.The text was updated successfully, but these errors were encountered: