关于路由验证
如何使用
路由验证部分的代码已经抽离,各自页面中,只需引入 routeAuth 方法,放于路由守卫中即可。代码如下:
router/index.ts:
import { routeAuth } from './routeAuth';
...
const routes: Array<RouteConfig> = [
{
path: '/',
name: 'Home',
component: Index,
// 在路由中写入原信息
meta: {
auth: 13
}
},
]
...
// 权限
router.beforeEach((to, from, next) => {
// 用户角色代码,为数组时表示权限只限数组内数字,为number时,表示大于等于该数字都有权限
const role =