N
N
nen0y2020-08-12 15:57:55
Vue.js
nen0y, 2020-08-12 15:57:55

How to write the correct route?

There are two types of pages:
1) With a sidebar
2) Without a sidebar

By default, all pages are displayed with a sidebar:

<template>
  <div id="app">
    <MainLayout />
  </div>
</template>


<template>
  <div class="pages">
    <Menu />
    <router-view />
  </div>
</template>


How to make it so that when you go to a page that should be without a sidebar, it is not displayed?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
fallus, 2020-08-12
@nen0y

For example so.
These are routes where you can create your own meta.

{
        name: 'myHomePage',
        path: '/',
        component: HomePage,
        meta: { sideBar: true }
},
{
        name: 'Products',
        path: '/',
        component: ProductsPage,
        meta: { sideBar: false }
},

If sidebar is , then:<Menu />
<Menu v-if="$route.meta && $route.meta.sideBar" />
spoiler
Ну а CSS потом лучше поправить, если правильно не сделано.
Если у роутов ширина фикцированная, учитывающая ширину меню, то лучше сделать примерно так:
#menu + .myRouteWrapper{
width: calc(100% - var(--menuWidth))
}

То есть, если Меню не будет отрендерено, то ширина контента будет 100% (наверное)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question