Reputation: 85
I am using a v-navigation-drawer on my webpage, but i want to disable it on specific routes, for example on the landing page. I am currently using the v-navigation-drawer in the App.vue file, as shown:
<v-app>
<v-navigation-drawer id ="nav"
persistent
:mini-variant="miniVariant"
:clipped="clipped"
v-model="drawer"
enable-resize-watcher
fixed
app
width="275"
mobile-break-point
>
<v-list style="width:275px">
<v-list-tile style="color: white"
value="true"
v-for="(item,i) in items"
:key="item.path"
@click="redirect(item.path)"
>
<v-list-tile-action style="color:#1872EF" >
<v-icon v-html="item.icon"></v-icon>
</v-list-tile-action>
<v-list-tile-content id="list">
<v-list-tile-title v-text="item.title"></v-list-tile-title>
</v-list-tile-content>
</v-list-tile>
</v-list>
</v-navigation-drawer>
<v-toolbar
app
:clipped-left="clipped"
style="background-color:#FFFFFF"
>
<p style="color:#DFDEE3" > Menu </p>
<img src="./assets/agilebot.svg" height="44" width="150">
<v-toolbar-title id="title"></v-toolbar-title>
</v-toolbar>
Which is the best way to disable it in specific routes ?
Upvotes: 2
Views: 2355
Reputation: 10977
Simple to use with $route it returns current route name in $route.name
<v-navigation-drawer v-if="$route.name!='home'">
In Router
routes: [
{ path: '/', component: Home, name: "home" },
Upvotes: 0
Reputation: 19012
You can do it by using v-if
(or even v-show)
<v-navigation-drawer v-if="['home'].indexOf($route.name) === -1">
home
being your landing page name in the router:
routes: [
{ path: '/', component: Home, name: "home" }, // names are arbitrary of course
And in array inside v-if just add list of route names where you don't want the drawer shown.
Upvotes: 3