Vue-router: Alias does't allow additional route param

Created on 23 May 2019  路  2Comments  路  Source: vuejs/vue-router

Version

3.0.6

Reproduction link

https://jsfiddle.net/ovk93q5e/

Steps to reproduce

When alias contains additional params

{
   path: "/:foo/explore/,
   alias: ["/:foo/explore/:extra/bar"],
}

route is matched on both urls, but extra parameter remains unset in $route.params

When decalared in reversed order

{
   path: "/:foo/explore/:extra/bar",
   alias: ["/:foo/explore/"],
}

Route is matched only by path and not by alias

What is expected?

Route params should contains values according to matched route.

What is actually happening?

Described in steps to reproduce.

Most helpful comment

@posva redirect is not solution in my case. I am going to declare another route pointing to same component. (but such solution requires much more effort especially together with Nuxt, alias with different params would be much much easier)

All 2 comments

A path and an alias should contain the same amount of params. Otherwise set another route with a redirect. That will allow you to provide a default param

@posva redirect is not solution in my case. I am going to declare another route pointing to same component. (but such solution requires much more effort especially together with Nuxt, alias with different params would be much much easier)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

shinygang picture shinygang  路  3Comments

Atinux picture Atinux  路  3Comments

baijunjie picture baijunjie  路  3Comments

rr326 picture rr326  路  3Comments

posva picture posva  路  3Comments