ng2-Chart 不适用于新创建的 angular 10 个项目

ng2-Chart not working with newly created angular 10 project

尝试将 ng2-charts 添加到新创建的 angular 项目时出现此错误

编译时好像有问题

我尝试并搜索了多种方法,但没有成功

error

这是我的 package.json

  "private": true,
  "dependencies": {
    "@angular/animations": "~10.1.0-next.7",
    "@angular/common": "~10.1.0-next.7",
    "@angular/compiler": "~10.1.0-next.7",
    "@angular/core": "~10.1.0-next.7",
    "@angular/forms": "~10.1.0-next.7",
    "@angular/platform-browser": "~10.1.0-next.7",
    "@angular/platform-browser-dynamic": "~10.1.0-next.7",
    "@angular/router": "~10.1.0-next.7",
    "chart.js": "^2.9.3",
    "ng2-charts": "^2.4.1",
    "rxjs": "~6.6.0",
    "tslib": "^2.0.0",
    "zone.js": "~0.10.2"
  },
    "devDependencies": {
    "@angular-devkit/build-angular": "~0.1001.0-next.6",
    "@angular/cli": "~10.1.0-next.6",
    "@angular/compiler-cli": "~10.1.0-next.7",
    "@types/node": "^12.11.1",
    "@types/jasmine": "~3.5.0",
    "@types/jasminewd2": "~2.0.3",
    "codelyzer": "^6.0.0",
    "jasmine-core": "~3.6.0",
    "jasmine-spec-reporter": "~5.0.0",
    "karma": "~5.0.0",
    "karma-chrome-launcher": "~3.1.0",
    "karma-coverage-istanbul-reporter": "~3.0.2",
    "karma-jasmine": "~4.0.0",
    "karma-jasmine-html-reporter": "^1.5.0",
    "protractor": "~7.0.0",
    "ts-node": "~8.3.0",
    "tslint": "~6.1.0",
    "typescript": "~3.9.5"
  }

这里是 app.module

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';

import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { ChartsModule } from 'ng2-charts/lib/charts.module';

@NgModule({
  declarations: [
    AppComponent,
  ],
  imports: [
    BrowserModule,
    AppRoutingModule,
    ChartsModule,
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

尝试按如下方式更改 ChartsModule 的导入:

import { ChartsModule } from 'ng2-charts';

请查看此 StackBlitz 以查看使用 Angular 10 的工作示例。