Angular 项目编译前运行正常,编译后运行报错

  • 我的 Angular 项目,没有编译使用 ng serve --o 运行,浏览器中查看正常并且没有报错
  • 使用:ng build --prod 编译后(编译中没有错误)拷贝到 tomcat 下能运行起来但是报错

StaticInjectorError(Platform: core)[class{constructor(e,t,n,i,o){this._overlay=e,this._dir=o,this._hasBackdrop=!1,this._lockPosition=!1,this._growAfterOpen=!1,this._flexibleDimensions=!1,this._push=!1,this._backdropSubscription=l.a.EMPTY,this.vi
Jo @ main-es2015.5fbfc01bfefd391d0e70.js:1
handleError @ main-es2015.5fbfc01bfefd391d0e70.js:1
(anonymous) @ main-es2015.5fbfc01bfefd391d0e70.js:1
invoke @ polyfills-es2015.5663d97d2ce982b62083.js:1
run @ polyfills-es2015.5663d97d2ce982b62083.js:1
runOutsideAngular @ main-es2015.5fbfc01bfefd391d0e70.js:1
tick @ main-es2015.5fbfc01bfefd391d0e70.js:1
_loadComponent @ main-es2015.5fbfc01bfefd391d0e70.js:1
bootstrap @ main-es2015.5fbfc01bfefd391d0e70.js:1
(anonymous) @ main-es2015.5fbfc01bfefd391d0e70.js:1
_moduleDoBootstrap @ main-es2015.5fbfc01bfefd391d0e70.js:1
(anonymous) @ main-es2015.5fbfc01bfefd391d0e70.js:1
invoke @ polyfills-es2015.5663d97d2ce982b62083.js:1
onInvoke @ main-es2015.5fbfc01bfefd391d0e70.js:1
invoke @ polyfills-es2015.5663d97d2ce982b62083.js:1
run @ polyfills-es2015.5663d97d2ce982b62083.js:1
(anonymous) @ polyfills-es2015.5663d97d2ce982b62083.js:1
invokeTask @ polyfills-es2015.5663d97d2ce982b62083.js:1
onInvokeTask @ main-es2015.5fbfc01bfefd391d0e70.js:1
invokeTask @ polyfills-es2015.5663d97d2ce982b62083.js:1
runTask @ polyfills-es2015.5663d97d2ce982b62083.js:1
_ @ polyfills-es2015.5663d97d2ce982b62083.js:1
Promise.then (async)
g @ polyfills-es2015.5663d97d2ce982b62083.js:1
scheduleTask @ polyfills-es2015.5663d97d2ce982b62083.js:1
onScheduleTask @ polyfills-es2015.5663d97d2ce982b62083.js:1
scheduleTask @ polyfills-es2015.5663d97d2ce982b62083.js:1
scheduleTask @ polyfills-es2015.5663d97d2ce982b62083.js:1
scheduleMicroTask @ polyfills-es2015.5663d97d2ce982b62083.js:1
C @ polyfills-es2015.5663d97d2ce982b62083.js:1
then @ polyfills-es2015.5663d97d2ce982b62083.js:1
appInitializer @ main-es2015.5fbfc01bfefd391d0e70.js:1
runInitializers @ main-es2015.5fbfc01bfefd391d0e70.js:1
(anonymous) @ main-es2015.5fbfc01bfefd391d0e70.js:1
(anonymous) @ main-es2015.5fbfc01bfefd391d0e70.js:1
(anonymous) @ main-es2015.5fbfc01bfefd391d0e70.js:1
invoke @ polyfills-es2015.5663d97d2ce982b62083.js:1
onInvoke @ main-es2015.5fbfc01bfefd391d0e70.js:1
invoke @ polyfills-es2015.5663d97d2ce982b62083.js:1
run @ polyfills-es2015.5663d97d2ce982b62083.js:1
run @ main-es2015.5fbfc01bfefd391d0e70.js:1
bootstrapModuleFactory @ main-es2015.5fbfc01bfefd391d0e70.js:1
zUnb @ main-es2015.5fbfc01bfefd391d0e70.js:1
a @ runtime-es2015.d764840f684025ed091a.js:1
0 @ main-es2015.5fbfc01bfefd391d0e70.js:1
a @ runtime-es2015.d764840f684025ed091a.js:1
t @ runtime-es2015.d764840f684025ed091a.js:1
r @ runtime-es2015.d764840f684025ed091a.js:1
(anonymous) @ main-es2015.5fbfc01bfefd391d0e70.js:1

- 是什么问题?我真的没看懂。。。
- 是打开首页成功显示了,但是浏览器控制台中报错,并且有个 ng-zorro-antd 的 overlay 组件没有正常显示
阅读 2.9k
1 个回答

StaticInjectorError错误一般来说是因为某个service没有provider引起。你可以检查一下这个包含overlay组件的页面的constructor(有5个参数,第一个参数应该就是那个overlay)里面注入的service,是否都有了provider,

或者这个constructor不是页面,而是zorro的overlay组件本身的constructor?你可以查看一下overlay组件的constructor是否有5个参数,第一个参数是否名字是overlay

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进