From ad0281839f84dd0f347236e0b6b35b60c17683bf Mon Sep 17 00:00:00 2001 From: xiaoxian521 <1923740402@qq.com> Date: Fri, 28 May 2021 01:14:05 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E9=87=87=E7=94=A8import.meta.glob?= =?UTF-8?q?=E6=96=B9=E6=B3=95=E5=8C=B9=E9=85=8D=E5=8A=A8=E6=80=81=E8=B7=AF?= =?UTF-8?q?=E7=94=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/router/index.ts | 7 ++++--- src/views/permission/page.vue | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/router/index.ts b/src/router/index.ts index cd380e211..b12ad66f3 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -10,6 +10,9 @@ import permissionRouter from "./modules/permission"; import remainingRouter from "./modules/remaining"; //静态路由 import Layout from "/@/layout/index.vue"; +// https://cn.vitejs.dev/guide/features.html#glob-import +const modulesRoutes = import.meta.glob("/src/views/*/*/*.vue"); + import { getAsyncRoutes } from "/@/api/routes"; import { storageSession } from "../utils/storage"; import { i18n } from "/@/plugins/i18n/index"; @@ -31,9 +34,7 @@ const addAsyncRoutes = (arrRoutes: Array) => { if (v.redirect) { v.component = Layout; } else { - // https://github.com/rollup/plugins/tree/master/packages/dynamic-import-vars#limitations - v.component = () => - import(/* @vite-ignore */ `/@/views${v.path}/index.vue`); + v.component = modulesRoutes[`/src/views${v.path}/index.vue`]; } if (v.children) { addAsyncRoutes(v.children); diff --git a/src/views/permission/page.vue b/src/views/permission/page.vue index c01936455..88c244cbf 100644 --- a/src/views/permission/page.vue +++ b/src/views/permission/page.vue @@ -3,7 +3,7 @@

当前角色: {{ purview }} -

查看左侧菜单变化(系统管理),模拟后台根据不同角色返回对应路由

+

查看左侧菜单变化(系统管理),模拟后台根据不同角色返回对应路由

切换角色