生产环境使用路由懒加载提升页面响应速度
This commit is contained in:
parent
e66d0e4f74
commit
519ea854d5
@ -106,8 +106,13 @@ function filterChildren(childrenMap, lastRouter = false) {
|
|||||||
return children
|
return children
|
||||||
}
|
}
|
||||||
|
|
||||||
export const loadView = (view) => { // 路由懒加载
|
export const loadView = (view) => {
|
||||||
return (resolve) => require([`@/views/${view}`], resolve)
|
if (process.env.NODE_ENV === 'development') {
|
||||||
|
return (resolve) => require([`@/views/${view}`], resolve)
|
||||||
|
} else {
|
||||||
|
// 使用 import 实现生产环境的路由懒加载
|
||||||
|
return () => import(`@/views/${view}`)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default permission
|
export default permission
|
||||||
|
Loading…
Reference in New Issue
Block a user