使用angular 12安装Plotly js时出错



我试图按照这篇文章在angular 12应用程序中安装plotly js。但是在typescript中出现了编译错误,

请帮我解决这个错误。

AppMoudle.ts

在遵循本文清除了上述编译问题之后,我得到了以下构建错误

构建错误

试试这个:

npm install angular-plotly.js plotly.js-dist-min --save
npm install @types/plotly.js-dist-min --save-dev

在AppModule中,做如下操作:

import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';

import { PlotlyViaCDNModule } from 'angular-plotly.js';

PlotlyViaCDNModule.setPlotlyVersion('latest');

@NgModule({
imports: [
CommonModule,
PlotlyViaCDNModule,
],
...
})
export class AppModule { }

使用Plotly.js的最新版本,但你也可以使用一个小版本。

你可以看看我在Angular 12中的项目:Plotly:

https://github.com/cristofima/AngularPlotly

最新更新