angular 14.2.0安装导入echarts出错

问题描述 投票:0回答:1

我需要安装 echarts,但是当我使用 npm 和命令安装它时:

npm 安装 echarts -S npm 安装 ngx-echarts -S npm install @types/echarts -D

整个安装过程进行得很顺利,但是当我尝试将它导入我的 app.module.ts 时,我得到了这个错误: Error on my screen

我已经尝试安装旧版本的 echarts 和 ngx-echarts,但似乎都不起作用。

这就是我的 app.module.ts 文件的样子:

import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { NgHttpLoaderModule } from 'ng-http-loader';
import { CommonModule } from '@angular/common';
import { SharedModule } from './shared/shared.module';
import { NgxEchartsModule } from 'ngx-echarts';
@NgModule({
  declarations: [AppComponent],
  imports: [
    BrowserModule,
    CommonModule,
    AppRoutingModule,
    SharedModule,
    NgxEchartsModule,
    NgHttpLoaderModule.forRoot(),
  ],
  bootstrap: [AppComponent],
})
export class AppModule {}

angular echarts
1个回答
0
投票

文档解释为:

import { NgxEchartsModule } from 'ngx-echarts';

@NgModule({
  imports: [
    NgxEchartsModule.forRoot({
      /**
       * This will import all modules from echarts.
       * If you only need custom modules,
       * please refer to [Custom Build] section.
       */
      echarts: () => import('echarts'), // or import('./path-to-my-custom-echarts')
    }),
  ],
})
export class AppModule {}

https://xieziyu.github.io/ngx-echarts/#/welcome

© www.soinside.com 2019 - 2024. All rights reserved.