From 519ea854d57f83feb6d6e992ce85eaad0a9acaaa Mon Sep 17 00:00:00 2001 From: RuoYi Date: Fri, 15 Oct 2021 17:57:46 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=9F=E4=BA=A7=E7=8E=AF=E5=A2=83=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=E8=B7=AF=E7=94=B1=E6=87=92=E5=8A=A0=E8=BD=BD=E6=8F=90?= =?UTF-8?q?=E5=8D=87=E9=A1=B5=E9=9D=A2=E5=93=8D=E5=BA=94=E9=80=9F=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ruoyi-ui/src/store/modules/permission.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/ruoyi-ui/src/store/modules/permission.js b/ruoyi-ui/src/store/modules/permission.js index 6143038a..4c8ed023 100644 --- a/ruoyi-ui/src/store/modules/permission.js +++ b/ruoyi-ui/src/store/modules/permission.js @@ -106,8 +106,13 @@ function filterChildren(childrenMap, lastRouter = false) { return children } -export const loadView = (view) => { // 路由懒加载 - return (resolve) => require([`@/views/${view}`], resolve) +export const loadView = (view) => { + if (process.env.NODE_ENV === 'development') { + return (resolve) => require([`@/views/${view}`], resolve) + } else { + // 使用 import 实现生产环境的路由懒加载 + return () => import(`@/views/${view}`) + } } export default permission