A Pen by John Leider on CodePen.
Created
December 27, 2020 01:44
-
-
Save calvinw/407299f6b1d146624a945b014763ff1c to your computer and use it in GitHub Desktop.
Vuetify Layout with Router
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div id="app"> | |
<v-app> | |
<v-navigation-drawer | |
app | |
clipped | |
> | |
<v-list> | |
<v-list-item | |
v-for="i in 3" | |
:key="i" | |
:to="{path: '/page' + i}" | |
> | |
<v-list-item-action> | |
<v-icon>mdi-{{ icons[i-1] }}</v-icon> | |
</v-list-item-action> | |
<v-list-item-content> | |
<v-list-item-title>Page {{ i }}</v-list-item-title> | |
</v-list-item-content> | |
</v-list-item> | |
</v-list> | |
</v-navigation-drawer> | |
<v-app-bar | |
app | |
clipped-left | |
> | |
<v-toolbar-title>App Bar</v-toolbar-title> | |
</v-app-bar> | |
<v-content> | |
<v-container fluid> | |
<v-fade-transition mode="out-in"> | |
<router-view></router-view> | |
</v-fade-transition> | |
</v-container> | |
</v-content> | |
</v-app> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Looking for v1.5 template? | |
// https://codepen.io/johnjleider/pen/GVoava | |
Vue.use(VueRouter) | |
let component1 = { | |
template:`<div class="title">Page 1</div>` | |
} | |
let component2 = { | |
template:`<div class="title">Page 2</div>` | |
} | |
let component3 = { | |
template:`<div class="title">Page 3</div>` | |
} | |
let router = new VueRouter({ | |
routes: [ | |
{ | |
path: '/page1', | |
name: 'Page 1', | |
component: component1, | |
}, | |
{ | |
path: '/page2', | |
name: 'Page 2', | |
component: component2, | |
}, | |
{ | |
path: '/page3', | |
name: 'Page Three', | |
component: component3, | |
}, | |
{ path: '*', redirect: '/page1' } | |
] | |
}) | |
new Vue({ | |
el: '#app', | |
router, | |
vuetify: new Vuetify(), | |
data: () => ({ | |
icons: ['widgets', 'home', 'heart'] | |
}) | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="https://cdn.jsdelivr.net/npm/vue@2.x/dist/vue.js"></script> | |
<script src="https://cdn.jsdelivr.net/npm/vuetify@2.x/dist/vuetify.js"></script> | |
<script src="https://unpkg.com/vue-router/dist/vue-router.js"></script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<link href="https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700,900" rel="stylesheet" /> | |
<link href="https://cdn.jsdelivr.net/npm/vuetify@2.x/dist/vuetify.min.css" rel="stylesheet" /> | |
<link href="https://cdn.jsdelivr.net/npm/@mdi/font@3.x/css/materialdesignicons.min.css" rel="stylesheet" /> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment