IPBS_V_Server_Web/router/router.js
2025-03-22 11:38:02 +08:00

43 lines
1.1 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import {createRouter, createWebHashHistory, createWebHistory} from 'vue-router'
import NProgress from 'nprogress'
import 'nprogress/nprogress.css'// nprogress样式文件
import UI_1 from "../src/components/Aside/UI_1.vue";
const routes = [
{
path: '/UI_1',
component: UI_1
},
];
const router = createRouter({
// history: createWebHistory(import.meta.env.BASE_URL),
history:createWebHashHistory(),
routes,
});
//当路由开始跳转时
router.beforeEach((to, from , next) => {
// 开启进度条
NProgress.start();
// 这个一定要加没有next()页面不会跳转的。这部分还不清楚的去翻一下官网就明白了
next();
});
//当路由跳转结束后
router.afterEach(() => {
// 关闭进度条
NProgress.done()
});
NProgress.configure({
easing: 'ease', // 动画方式
speed: 500, // 递增进度条的速度
showSpinner: false, // 是否显示加载ico
trickleSpeed: 200, // 自动递增间隔
minimum: 0.3 // 初始化时的最小百分比
})
export default router