Solve the problem of Error: Cannot find module '@/views/xxx' after Ruoyi deployment, and there is no problem locally

Problem Description:

If there is no problem running locally according to the project, after deploying to the server, click the menu to switch the route, and it is always in the loading state. When you open the console, you will find an error Error: Cannot find module '@/views/xxx'.

reason:

Lazy loading of routes, webpack version problem, webpack4 does not support dynamic import of variables, the new version needs to use require() to solve this problem.

Solution:

The first place , store/modules/permission.js. Syntax: return (resolve) => require([`@/views/${view}`], resolve)

The second place , router/index.js.

 result:

Successfully solved~

 

 

Guess you like

Origin blog.csdn.net/shilingling905/article/details/127981496