Skip to content

Ability to set parent named view from child route #3306

@Mikilll94

Description

@Mikilll94

What problem does this feature solve?

I have the following router configuration:

{
    path: '/home',
    components: {
        default: HomePage,
        leftSidebar: DefaultLeftSidebar
    },
    children: [
        {
            path: 'emails',
            component: UserEmailsSubscriptions
        },
        {
            path: 'profile',
            components: {
                default: UserProfile,
                leftSidebar: UserProfileLeftSidebar, // not possible
            }
        }
    ]
}

As you can see, on route /home I use a named view for the left sidebar. I need to replace this sidebar with UserProfileLeftSidebar on /home/profile route. However, this not possible because leftSidebar named view is defined in the parent view.

I think that this a pretty common use case that you have a navigation bar or sidebar that needs to be replaced or modified on some router paths.

I would be very glad if someone could share a solution how to implement a dynamic sidebar or navigation bar using vue-router.

What does the proposed API look like?

The API could look like in the example above. However, it requires that every named view must have globally unique name.

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