1 main.ts 引入路由和权限校验
import router from "./router";
//路由守卫权限拦截 2-2
import "@/router/permisstion";
2router 文件夹,三个文件
1.1indexe.ts
import { createRouter, createWebHistory } from "vue-router";
import { constRouter } from "./routers";
const router = createRouter({
history: createWebHistory(import.meta.env.BASE_URL),
routes: constRouter,
scrollBehavior() {
return {
left: 0,
top: 0,
};
},
});
export default router;
1.2 promisstions.ts
//路由守卫权限拦截 2-1
import router from "@/router";
//获取 token
import useUserStore from "@/stores/user";
import { createPinia } from "pinia";
const userStore = useUserS
标签:权限,const,vue3,ts,router,import,跳转,路由
From: https://blog.csdn.net/jieweiwujie/article/details/142336868