Skip to content

[ request/regression ] inherit route params  #850

@wjmao88

Description

@wjmao88

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?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions