Unexpected module ‘BrowserModule’ declared by the module ‘AppModule’

整体报错是:compiler.js:2175 Uncaught Error: Unexpected module ‘BrowserModule’ declared by the module ‘AppModule’. Please add a @Pipe/@Directive/@Component annotation.

把app.module和BrowserModule都翻了一遍,没发现什么问题.
之后查了很多网页,才发现.BrowserModule的位置放错了.它是一个’module’,而不是’component’,所以不应该被’declare’,而是该被’imports’;换一下位置就好了.

改之前:
Unexpected module 'BrowserModule' declared by the module 'AppModule'

改之后:
Unexpected module 'BrowserModule' declared by the module 'AppModule'

相关文章:

  • 2022-12-23
  • 2021-09-20
  • 2021-06-22
  • 2021-08-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-08
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-07-30
  • 2022-12-23
  • 2022-12-23
  • 2022-02-13
  • 2021-06-28
  • 2021-07-11
相关资源
相似解决方案