Nuxt.js: Dynamic route parameter is always generated as optional

Created on 1 Jul 2017  路  5Comments  路  Source: nuxt/nuxt.js

According to documentation route parameter should be generated as required when it's created by underscored directory. It is not.

structure

is generating:

    {
        path: "/ile-kosztuje/usluga/:service?",
        component: _6fec3b26,
        name: "ile-kosztuje-usluga-service"
    }

This question is available on Nuxt.js community (#c883)
available soon help-wanted

Most helpful comment

Was there ever an answer to this? What the OP is asking can certainly be accomplished in the component itself. But as he mentioned - the behavior doesn't match what the docs say. Creating /post/_id/index.vue still creates an optional parameter.

All 5 comments

Can you create _service.vue instead of being a directory?
So you will have:

  • usluga/
    --| index.vue
    --| _service.vue

I have a issue with the solution. Why create a new index.vue just to mitigate the optional? Why not just make the directory behaviour default for compulsory parameters? Also top level _dir seems to work but nested ones do not. What is the reason for not supporting it in the nested ones? I think this is a bug either documention or implementation.

Was there ever an answer to this? What the OP is asking can certainly be accomplished in the component itself. But as he mentioned - the behavior doesn't match what the docs say. Creating /post/_id/index.vue still creates an optional parameter.

@lfallo1 did you solved this issue?

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mattdharmon picture mattdharmon  路  3Comments

lazycrazy picture lazycrazy  路  3Comments

danieloprado picture danieloprado  路  3Comments

pehbehbeh picture pehbehbeh  路  3Comments

vadimsg picture vadimsg  路  3Comments