This commit is contained in:
@@ -1,11 +1,23 @@
|
||||
import { createRouter, createWebHistory } from "vue-router";
|
||||
import { RouteRecordRaw } from "vue-router";
|
||||
// NP
|
||||
import NProgress from "nprogress"; // progress bar
|
||||
import "nprogress/nprogress.css"; // progress bar style
|
||||
NProgress.configure({ easing: "ease", speed: 500, showSpinner: false });
|
||||
NProgress.inc(0.2);
|
||||
// End
|
||||
import Home from "../views/Home.vue";
|
||||
const routes = [
|
||||
const routes: Array<RouteRecordRaw> = [
|
||||
{
|
||||
path: "/",
|
||||
name: "Home",
|
||||
component: Home,
|
||||
},
|
||||
{
|
||||
path: "/about",
|
||||
name: "About",
|
||||
component: () => import("@/views/About.vue"),
|
||||
},
|
||||
];
|
||||
|
||||
// createRouter
|
||||
@@ -14,4 +26,13 @@ const router = createRouter({
|
||||
routes,
|
||||
});
|
||||
|
||||
router.beforeEach((to, from, next) => {
|
||||
NProgress.start();
|
||||
next();
|
||||
});
|
||||
|
||||
router.afterEach(() => {
|
||||
NProgress.done();
|
||||
});
|
||||
|
||||
export default router;
|
||||
|
10
src/views/About.vue
Normal file
10
src/views/About.vue
Normal file
@@ -0,0 +1,10 @@
|
||||
<template>
|
||||
<div>About</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {};
|
||||
</script>
|
||||
|
||||
<style>
|
||||
</style>
|
@@ -1,5 +1,9 @@
|
||||
<template>
|
||||
<div><el-button type="primary">ElementUI</el-button></div>
|
||||
<div>
|
||||
<el-button type="primary" @click="$router.push('/about')"
|
||||
>ElementUI</el-button
|
||||
>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
@@ -7,4 +11,4 @@ export default {};
|
||||
</script>
|
||||
|
||||
<style>
|
||||
</style>
|
||||
</style>
|
||||
|
Reference in New Issue
Block a user