From da785d402648c585e2b8031a964c7e21495e4108 Mon Sep 17 00:00:00 2001 From: wj <1285151836@qq.com> Date: Fri, 28 Apr 2023 10:23:46 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B7=AF=E7=94=B1=E4=BB=8Eimport=E6=94=B9?= =?UTF-8?q?=E4=B8=BArequire?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/router/index.js | 24 ++++++++++++------------ src/store/modules/permission.js | 3 ++- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/router/index.js b/src/router/index.js index f15f15e3..d8e35873 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -37,28 +37,28 @@ export const constantRoutes = [ children: [ { path: '/redirect/:path(.*)', - component: () => import('@/views/redirect') + component: (resolve) => require([`@/views/redirect`],resolve) } ] }, { path: '/login', - component: () => import('@/views/myLogin'), + component: (resolve) => require([`@/views/myLogin`],resolve), hidden: true }, { path: '/register', - component: () => import('@/views/register'), + component: (resolve) => require([`@/views/register`],resolve), hidden: true }, { path: '/404', - component: () => import('@/views/error/404'), + component: (resolve) => require([`@/views/error/404`],resolve), hidden: true }, { path: '/401', - component: () => import('@/views/error/401'), + component: (resolve) => require([`@/views/error/401`],resolve), hidden: true }, { @@ -68,7 +68,7 @@ export const constantRoutes = [ children: [ { path: 'index', - component: () => import('@/views/index'), + component: (resolve) => require([`@/views/index`],resolve), name: 'Index', meta: { title: '首页', icon: 'dashboard', affix: true } } @@ -82,7 +82,7 @@ export const constantRoutes = [ children: [ { path: 'profile', - component: () => import('@/views/system/user/profile/index'), + component: (resolve) => require([`@/views/system/user/profile/index`],resolve), name: 'Profile', meta: { title: '个人中心', icon: 'user' } } @@ -100,7 +100,7 @@ export const dynamicRoutes = [ children: [ { path: 'role/:userId(\\d+)', - component: () => import('@/views/system/user/authRole'), + component: (resolve) => require([`@/views/system/user/authRole`],resolve), name: 'AuthRole', meta: { title: '分配角色', activeMenu: '/system/user' } } @@ -114,7 +114,7 @@ export const dynamicRoutes = [ children: [ { path: 'user/:roleId(\\d+)', - component: () => import('@/views/system/role/authUser'), + component: (resolve) => require([`@/views/system/role/authUser`],resolve), name: 'AuthUser', meta: { title: '分配用户', activeMenu: '/system/role' } } @@ -128,7 +128,7 @@ export const dynamicRoutes = [ children: [ { path: 'index/:dictId(\\d+)', - component: () => import('@/views/system/dict/data'), + component: (resolve) => require([`@/views/system/dict/data`],resolve), name: 'Data', meta: { title: '字典数据', activeMenu: '/system/dict' } } @@ -142,7 +142,7 @@ export const dynamicRoutes = [ children: [ { path: 'index', - component: () => import('@/views/system/oss/config'), + component: (resolve) => require([`@/views/system/oss/config`],resolve), name: 'OssConfig', meta: { title: '配置管理', activeMenu: '/system/oss' } } @@ -156,7 +156,7 @@ export const dynamicRoutes = [ children: [ { path: 'index/:tableId(\\d+)', - component: () => import('@/views/tool/gen/editTable'), + component: (resolve) => require([`@/views/tool/gen/editTable`],resolve), name: 'GenEdit', meta: { title: '修改生成配置', activeMenu: '/tool/gen' } } diff --git a/src/store/modules/permission.js b/src/store/modules/permission.js index 22876655..acf853a4 100644 --- a/src/store/modules/permission.js +++ b/src/store/modules/permission.js @@ -126,7 +126,8 @@ export const loadView = (view) => { return (resolve) => require([`@/views/${view}`], resolve) } else { // 使用 import 实现生产环境的路由懒加载 - return () => import(`@/views/${view}`) +// return () => import(`@/views/${view}`) + return (resolve) => require([`@/views/${view}`], resolve) } }