1

一些内容:Angular 版本:5.2.0

""@angular/common": "^5.2.0",
"@angular/compiler": "^5.2.0", "rxjs": "^5.5.6","

我正在尝试安装Ng Ant Design。我知道最新版本可能是在 Angular 7 上构建的,所以我采用了以前的版本。

"ng-zorro-antd": "1.8.1"

我收到 Angular CDK 的错误,所以我故意安装

"@angular/cdk": "^5.2.0",
"@angular/material": "^5.2.0"

但我仍然收到这些错误

`ERROR in node_modules/ng-zorro-antd/node_modules/@angular/cdk/observers/typings/observe-content.d.ts(26,22): error TS2315: Type 'ElementRef' is not generic.

node_modules/ng-zorro-antd/node_modules/@angular/cdk/observers/typings/observe-content.d.ts(60,65): error TS2315: Type 'ElementRef' is not generic. node_modules/ng-zorro-antd/node_modules/@angular/cdk/overlay/typings/position/connected-position-strategy.d.ts(33,106): error TS2315: Type 'ElementRef' is not generic. node_modules/ng-zorro-antd/node_modules/@angular/cdk/a11y/typings/focus-monitor/focus-monitor.d.ts(117,30): error TS2315: Type 'ElementRef' is not generic. node_modules/ng-zorro-antd/node_modules/@angular/cdk/a11y/typings/focus-trap/focus-trap.d.ts(118,30): error TS2315: Type 'ElementRef' is not generic. node_modules/ng-zorro-antd/drawer/nz-drawer-ref.d.ts(1,28): error TS2307: Cannot find module 'rxjs/index'.

package-lock.json 文件显示了这一点,所以我也尝试安装“@angular/cdk”:“6.4.7”,但得到了同样的错误。

"ng-zorro-antd": {
  "version": "1.8.1",
  "resolved": "https://registry.npmjs.org/ng-zorro-antd/-/ng-zorro-antd-1.8.1.tgz",
  "integrity": "sha512-XNEwzt535/rILb/tEEwYBd2Ex4B4BwH7dzlbJAcpZZnN2tbIJYGNUiwbHo/o6t41Fv0qAgF/zmIlI0wQH+U7yA==",
  "requires": {
    "@angular/cdk": "^6.0.0",
    "@ant-design/icons-angular": "^1.0.1",
    "date-fns": "^1.29.0",
    "tslib": "^1.9.0"
  },
  "dependencies": {
    "@angular/cdk": {
      "version": "6.4.7",
      "resolved": "https://registry.npmjs.org/@angular/cdk/-/cdk-6.4.7.tgz",
      "integrity": "sha512-18x0U66fLD5kGQWZ9n3nb75xQouXlWs7kUDaTd8HTrHpT1s2QIAqlLd1KxfrYiVhsEC2jPQaoiae7VnBlcvkBg==",
      "requires": {
        "tslib": "^1.7.1"
      }
    }
  }
}
4

1 回答 1

1

你有两个选择:

  • 将您的 Angular 依赖项升级到版本 7 并安装新的 NgZorro
  • 将 NgZorro 降级到版本 0.7.1 以获得与 Angular 5.x 兼容的版本

有关它们的依赖历史记录,请参阅 package.json https://github.com/NG-ZORRO/ng-zorro-antd/blob/0.7.1/package.json

于 2019-03-16T09:39:37.067 回答