Skip to content

Instantly share code, notes, and snippets.

@mhaecal
Created August 7, 2022 07:30
Show Gist options
  • Save mhaecal/3ab7a7ccd02cf18d1afcc0232e8d6114 to your computer and use it in GitHub Desktop.
Save mhaecal/3ab7a7ccd02cf18d1afcc0232e8d6114 to your computer and use it in GitHub Desktop.
Vue Router Layout System
<script setup lang="ts"></script>
<template>
<h1>admin layout</h1>
<router-view></router-view>
</template>
import { createRouter, createWebHistory } from 'vue-router'
// component
import Home from '../pages/Home.vue'
import AdminLayout from '../components/layouts/AdminLayout.vue'
const routes = [
{
path: '/',
name: 'Home',
component: Home,
},
{
path: '/',
component: AdminLayout,
children: [
{
path: '/dashboard',
name: 'Dashboard',
component: () => import('../pages/Dashboard.vue'),
meta: { auth: true },
},
],
},
{
path: '/login',
name: 'Login',
component: () => import('../pages/Login.vue'),
},
]
const router = createRouter({
history: createWebHistory(),
routes,
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment