Search code examples
vue-routernuxt.js

Is it possible in Nuxt.js to have multiple route parameters with same level hierarchy?


Is it possible in Nuxt.js to have multiple route parameters with same level hierarchy? For instance:

- entry
-- _id.vue
-- _slug.vue
- index.js

Solution

  • No, it's not possible.

    But you can use a simple workaround.

    Case 1

    You need both _id and _slug in the same route. Then you can simply nest them. So that your route will look like this: entry/_id/_slug. And your files would look like this:

    entry/
    --| _id/
    -----| index.vue //this one is for _id
    -----| _slug/
    --------| index.vue //this one is for _slug
    

    Also you can swap _id with _slug if it fits your needs better.

    Case 2

    You need two different routes: entry/id/_id and entry/slug/_slug. In this case your files would look like this:

    entry/
    --| id/
    -----| _id.vue
    --| slug/
    -----| _slug.vue