angular配置懒加载core.js:14597 ERROR Error: Uncaught (in promise): TypeError: undefined is not a function

懒加载配置命令(详细配置国产可以直接中官网上查看):ng g module student  --routing

student 为模块名称,执行完毕后会生成一下两个文件:

student.module.ts

student-routing.module.ts

 

angualr配置懒加载启动使用 ng s 命令启动,然后访问的时候,路由不起作用了错误信息如下:

core.js:14597 ERROR Error: Uncaught (in promise): TypeError: undefined is not a function
TypeError: undefined is not a function
    at Array.map ()
    at webpackAsyncContext ($_lazy_route_resource lazy namespace object:18)
    at SystemJsNgModuleLoader.loadAndCompile (core.js:17170)
    at SystemJsNgModuleLoader.load (core.js:17162)
    at RouterConfigLoader.loadModuleFactory (router.js:3608)
    at RouterConfigLoader.load (router.js:3596)
    at MergeMapSubscriber.project (router.js:2605)
    at MergeMapSubscriber._tryNext (mergeMap.js:61)
    at MergeMapSubscriber._next (mergeMap.js:51)
    at MergeMapSubscriber.Subscriber.next (Subscriber.js:54)
    at resolvePromise (zone.js:831)
    at resolvePromise (zone.js:788)
    at zone.js:892
    at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:423)
    at Object.onInvokeTask (core.js:16147)
    at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:422)
    at Zone.push../node_modules/zone.js/dist/zone.js.Zone.runTask (zone.js:195)
    at drainMicroTaskQueue (zone.js:601)
    at ZoneTask.push../node_modules/zone.js/dist/zone.js.ZoneTask.invokeTask [as invoke] (zone.js:502)
    at invokeTask (zone.js:1744)

 

检查的配置,感觉没错,搜索了半天有人说用 ng s --aot启动,试了一下果然可以。

你可能感兴趣的:(Angular,JS,WEB前端)