Skip to content

Add ability to dynamically add child routes #2020

Closed
@smares

Description

@smares

Version

3.0.1

Reproduction link

https://jsfiddle.net/qv9z3x99/

Steps to reproduce

vue-router has a method addRoutes that allows to dynamically add routes. However, it is currently not possible to add child routes to an existing route as far as I can see. It would be nice if addRoutes could have a second parameter parent or if you could introduce a new addChildRoutes method.

What I am trying to achieve is create a route for a product, let's say '/products/productA' pointing to a component that dynamically adds child routes in its beforeCreate so that in the end, I can navigate to '/products/productA/settings', '/products/productA/dashboard' etc. without the main router config knowing about every route each product has.

What is expected?

addRoute should offer a second parameter called parent so one can add child routes

What is actually happening?

addRoute does not support adding child routes to routes already defined

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions