Skip to content

Disable a component on some routes? #254

@joedawson

Description

@joedawson

Hello,

I'm not sure if this the correct way of thinking - but I want one of my components to be disabled or deactivated on some routes.

So here's my routes.

router.map({
    '/':                        { component: ProductsView },
    '/auth/login':              { component: LoginView },
    '/auth/register':           { component: RegisterView },
    '/products':                { component: ProductsView },
    '/products/:product':       { component: ProductView },
    '/categories':              { component: CategoriesView },
    '/categories/:category':    { component: CategoryView },
    '*':                        { component: NotFoundView }
});

My main template file looks like so:

<!DOCTYPE html>
<html lang="en" id="app">
    <head>
        <!-- Head Contents -->
    </head>
    <body>
        <header>
            <!-- Header Contents -->
            <navigation></navigation>
        </header>
        <div class="container">
            <router-view></router-view>
        </div>
    </body>
</html>

When I'm on either the /auth/login or /auth/register routes - I do not want my navigation component to appear.

How can I achieve this?

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