0

我尝试在我的项目中使用 ANT Design NG-ZORRO 库。但是当我编译代码时,我收到以下警告:

WARNING in ./node_modules/ng-zorro-antd/fesm5/ng-zorro-antd-core.js 2294:66-84
"export 'ɵɵdefineInjectable' was not found in '@angular/core'

这会导致运行时错误:

Uncaught TypeError: Object(...) is not a function
    at ng-zorro-antd-core.js:2294
    at Module../node_modules/ng-zorro-antd/fesm5/ng-zorro-antd-core.js (ng-zorro-antd-core.js:2296)

我搜索了互联网并尝试了所涉及软件包的各种版本组合。但无法让它工作。

package.json 的摘录:

"dependencies": {
    "@angular/animations": "^7.2.15",
    "@angular/common": "^7.2.13",
    "@angular/compiler": "^7.2.13",
    "@angular/core": "^7.2.13",
    "@angular/forms": "^7.2.13",
    "@angular/http": "^7.2.13",
    "@angular/platform-browser": "^7.2.13",
    "@angular/platform-browser-dynamic": "^7.2.13",
    "@angular/platform-server": "^7.2.13",
    "@angular/router": "^7.2.13",
    "@aspnet/signalr": "^1.1.4",
    "@fortawesome/angular-fontawesome": "^0.3.0",
    "@fortawesome/fontawesome-svg-core": "^1.2.22",
    "@fortawesome/free-regular-svg-icons": "^5.10.2",
    "@fortawesome/free-solid-svg-icons": "^5.10.2",
    "@nguniversal/module-map-ngfactory-loader": "^7.1.1",
    "ajv": "^6.10.0",
    "aspnet-prerendering": "^3.0.1",
    "bootstrap": "^4.3.1",
    "core-js": "2.6.5",
    "jquery": "^3.4.0",
    "messagepack": "^1.1.10",
    "ng-zorro-antd": "^8.3.0",
    "popper.js": "^1.15.0",
    "rtcp-web-viewer": "^2.0.3",
    "rxjs": "^6.5.3",
    "zone.js": "^0.9.1"
  }

我需要做什么来解决这些警告和错误以使包正常工作?

4

1 回答 1

1

这是因为您使用的ng-zorro-antd库版本与您正在使用的 Angular 库不兼容。

库的版本8.0.0和更高版本ng-zorro-antd要求您更新 Angular 依赖项以使用版本8.0.0及更高版本(有关更多信息,请参阅版本说明8.0.0)。

因此,您必须:

  • 将您的 Angular 依赖项更新到版本 8 及更高版本(有关如何更新的详细信息,请参阅Angular 更新指南),或

  • 将库降级ng-zorro-antd到旧版本(在这种情况下,您应该使用最新7.x.x版本 - 7.5.1

于 2019-09-11T10:03:16.157 回答