Created
August 7, 2022 07:30
-
-
Save mhaecal/3ab7a7ccd02cf18d1afcc0232e8d6114 to your computer and use it in GitHub Desktop.
Vue Router Layout System
This file contains hidden or 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 setup lang="ts"></script> | |
<template> | |
<h1>admin layout</h1> | |
<router-view></router-view> | |
</template> |
This file contains hidden or 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
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