import { useStore } from '@/stores/index'
...
routes: [
{
path: '/',
name: 'home',
component: () => import('@/layout/index.vue'),
redirect: to => {
// 方法接收目标路由作为参数
// return 重定向的字符串路径/路径对象
const store = useStore()
const menus = store.userInfo?.menus || []
return { name: menus[0]?.children[0]?.name || '' }
},
children: [
...
vue-router根据权限动态设定路由重定向 redirect 的路径
于 2024-08-20 15:29:37 首次发布