IPBS_V_Server_Web/router/router.js

53 lines
1.3 KiB
JavaScript
Raw Normal View History

2025-03-22 11:38:02 +08:00
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";
2025-05-05 10:43:58 +08:00
import UI_2 from "../src/components/Aside/UI_2.vue";
2025-09-27 17:52:05 +08:00
import UI_3 from "../src/components/Aside/UI_3.vue";
2025-03-22 11:38:02 +08:00
const routes = [
{
path: '/UI_1',
component: UI_1
},
2025-05-05 10:43:58 +08:00
{
path: '/UI_2',
component: UI_2
},
2025-09-27 17:52:05 +08:00
{
path: '/UI_3',
component: UI_3
},
2025-03-22 11:38:02 +08:00
];
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