Commit da5c1328beb06a4c785aa2791a2b9ca3bbeefaa6
1 parent
aae18256
修复路由懒加载报错问题
Showing
2 changed files
with
10 additions
and
10 deletions
ruoyi-ui/src/router/index.js
| @@ -33,23 +33,23 @@ export const constantRoutes = [ | @@ -33,23 +33,23 @@ export const constantRoutes = [ | ||
| 33 | children: [ | 33 | children: [ |
| 34 | { | 34 | { |
| 35 | path: '/redirect/:path(.*)', | 35 | path: '/redirect/:path(.*)', |
| 36 | - component: () => import('@/views/redirect') | 36 | + component: (resolve) => require(['@/views/redirect'], resolve) |
| 37 | } | 37 | } |
| 38 | ] | 38 | ] |
| 39 | }, | 39 | }, |
| 40 | { | 40 | { |
| 41 | path: '/login', | 41 | path: '/login', |
| 42 | - component: () => import('@/views/login'), | 42 | + component: (resolve) => require(['@/views/login'], resolve), |
| 43 | hidden: true | 43 | hidden: true |
| 44 | }, | 44 | }, |
| 45 | { | 45 | { |
| 46 | path: '/404', | 46 | path: '/404', |
| 47 | - component: () => import('@/views/error/404'), | 47 | + component: (resolve) => require(['@/views/error/404'], resolve), |
| 48 | hidden: true | 48 | hidden: true |
| 49 | }, | 49 | }, |
| 50 | { | 50 | { |
| 51 | path: '/401', | 51 | path: '/401', |
| 52 | - component: () => import('@/views/error/401'), | 52 | + component: (resolve) => require(['@/views/error/401'], resolve), |
| 53 | hidden: true | 53 | hidden: true |
| 54 | }, | 54 | }, |
| 55 | { | 55 | { |
| @@ -59,7 +59,7 @@ export const constantRoutes = [ | @@ -59,7 +59,7 @@ export const constantRoutes = [ | ||
| 59 | children: [ | 59 | children: [ |
| 60 | { | 60 | { |
| 61 | path: 'index', | 61 | path: 'index', |
| 62 | - component: () => import('@/views/index'), | 62 | + component: (resolve) => require(['@/views/index'], resolve), |
| 63 | name: '首页', | 63 | name: '首页', |
| 64 | meta: { title: '首页', icon: 'dashboard', noCache: true, affix: true } | 64 | meta: { title: '首页', icon: 'dashboard', noCache: true, affix: true } |
| 65 | } | 65 | } |
| @@ -73,7 +73,7 @@ export const constantRoutes = [ | @@ -73,7 +73,7 @@ export const constantRoutes = [ | ||
| 73 | children: [ | 73 | children: [ |
| 74 | { | 74 | { |
| 75 | path: 'profile', | 75 | path: 'profile', |
| 76 | - component: () => import('@/views/system/user/profile/index'), | 76 | + component: (resolve) => require(['@/views/system/user/profile/index'], resolve), |
| 77 | name: 'Profile', | 77 | name: 'Profile', |
| 78 | meta: { title: '个人中心', icon: 'user' } | 78 | meta: { title: '个人中心', icon: 'user' } |
| 79 | } | 79 | } |
| @@ -86,7 +86,7 @@ export const constantRoutes = [ | @@ -86,7 +86,7 @@ export const constantRoutes = [ | ||
| 86 | children: [ | 86 | children: [ |
| 87 | { | 87 | { |
| 88 | path: 'type/data/:dictId(\\d+)', | 88 | path: 'type/data/:dictId(\\d+)', |
| 89 | - component: () => import('@/views/system/dict/data'), | 89 | + component: (resolve) => require(['@/views/system/dict/data'], resolve), |
| 90 | name: 'Data', | 90 | name: 'Data', |
| 91 | meta: { title: '字典数据', icon: '' } | 91 | meta: { title: '字典数据', icon: '' } |
| 92 | } | 92 | } |
| @@ -99,7 +99,7 @@ export const constantRoutes = [ | @@ -99,7 +99,7 @@ export const constantRoutes = [ | ||
| 99 | children: [ | 99 | children: [ |
| 100 | { | 100 | { |
| 101 | path: 'log', | 101 | path: 'log', |
| 102 | - component: () => import('@/views/monitor/job/log'), | 102 | + component: (resolve) => require(['@/views/monitor/job/log'], resolve), |
| 103 | name: 'JobLog', | 103 | name: 'JobLog', |
| 104 | meta: { title: '调度日志' } | 104 | meta: { title: '调度日志' } |
| 105 | } | 105 | } |
| @@ -112,7 +112,7 @@ export const constantRoutes = [ | @@ -112,7 +112,7 @@ export const constantRoutes = [ | ||
| 112 | children: [ | 112 | children: [ |
| 113 | { | 113 | { |
| 114 | path: 'edit', | 114 | path: 'edit', |
| 115 | - component: () => import('@/views/tool/gen/editTable'), | 115 | + component: (resolve) => require(['@/views/tool/gen/editTable'], resolve), |
| 116 | name: 'GenEdit', | 116 | name: 'GenEdit', |
| 117 | meta: { title: '修改生成配置' } | 117 | meta: { title: '修改生成配置' } |
| 118 | } | 118 | } |
ruoyi-ui/src/store/modules/permission.js
| @@ -48,7 +48,7 @@ function filterAsyncRouter(asyncRouterMap) { | @@ -48,7 +48,7 @@ function filterAsyncRouter(asyncRouterMap) { | ||
| 48 | } | 48 | } |
| 49 | 49 | ||
| 50 | export const loadView = (view) => { // 路由懒加载 | 50 | export const loadView = (view) => { // 路由懒加载 |
| 51 | - return () => import(`@/views/${view}`) | 51 | + return (resolve) => require([`@/views/${view}`], resolve) |
| 52 | } | 52 | } |
| 53 | 53 | ||
| 54 | export default permission | 54 | export default permission |