【问题标题】:Cannot access 'MyComponent' before initialization in Angular 10在 Angular 10 中初始化之前无法访问“MyComponent”
【发布时间】:2021-01-30 04:42:48
【问题描述】:

我在浏览器中收到Cannot access 'MyComponent' before initialization 错误消息。

ng build 运行没有错误。

我对此主题进行了一些研究,并找到了使用此设置更新我的应用程序的 tsconfig.base.json 文件的建议:

{
  "compilerOptions": {
    "emitDecoratorMetadata": false
  }
}

这没有帮助。所以添加了这个:

  "annotateForClosureCompiler": {
    "annotateForClosureCompiler": true
  }

也没有帮助。因此尝试将targetes2015 更改为任何新的但未解决问题。

我也尝试在我的库中更改这些设置(包含组件的内容),但没有帮助。

我检查了这些讨论:

在我的例子中,我使用来自 Angular 包的10.1.6

{
  "dependencies": {
    "@angular/animations": "^10.1.6",
    "@angular/cdk": "^10.2.5",
    "@angular/common": "^10.1.6",
    "@angular/compiler": "^10.1.6",
    "@angular/core": "^10.1.6",
    "@angular/forms": "^10.1.6",
    "@angular/material": "^10.2.5",
    "@angular/platform-browser": "^10.1.6",
    "@angular/platform-browser-dynamic": "^10.1.6",
    "@angular/router": "^10.1.6",
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "^0.1001.3",
    "@angular/cli": "^10.1.7",
    "@angular/compiler-cli": "^10.1.6",
  }
}

有什么想法吗?

【问题讨论】:

    标签: angular angular-library angular10


    【解决方案1】:

    我解决了对我的库的循环依赖,并且错误消失了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-12-29
      • 2021-09-10
      • 2020-10-23
      • 2021-05-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多