Skip to content

[ request/regression ] inherit route params #850

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

Closed
wjmao88 opened this issue Oct 28, 2016 · 2 comments
Closed

[ request/regression ] inherit route params #850

wjmao88 opened this issue Oct 28, 2016 · 2 comments

Comments

@wjmao88
Copy link
Contributor

wjmao88 commented Oct 28, 2016

Basically as described in

http://archive.forum.vuejs.org/topic/1254/how-to-inherit-route-params-with-v-link

Suppose I have the following router setup:

router.map({
  '/a/:a': {
    name: 'a',
    component: ComponentA,

    subRoutes: {
      '/b/:b': {
        name: 'b',
        component: ComponentB,
      }
    }
  }
})
and the following HTML for ComponentA:

<a v-link="{ name: 'b', params: { b: 'banana' } }">Go to B</a>
then if I am at the address /a/apple and I click the link, I will end up at /a/undefined/b/banana. Why isn't the a param inherited from the current params? Is this intentional?

Am I supposed to do this instead:

<a v-link="{ name: 'b', params: { a: $route.params.a, b: 'banana' } }">Go to B</a>
but surely that will get messy real quick, especially if there are lots of params.

However, in the new version this behavior is no longer available, and attempting to define a link with incomplete params throws an error during link render from fillParams.

This was fixed in version v0.7.8 by https://github.com/vuejs/vue-router/blob/1.0/src/route.js#L25

Was there a good reason this behavior was removed? Can it be re-added?

@decademoon
Copy link
Contributor

I'm the OP of that forum post, and now that I'm upgrading to Vue 2 I have the same problem again. I have lots of links, so this will be a pain to make work.

@yyx990803
Copy link
Member

Thanks for the PR @wjmao88 !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants