Angular中使用echarts图标库时报了如下错误:
core.js:6189 ERROR Error: Component series.line not exists. Load it first.
at Function.entity.getClass (clazz.js:178)
at ExtendedClass.<anonymous> (Global.js:223)
at Array.forEach (<anonymous>)
at each (util.js:300)
at ExtendedClass.visitComponent (Global.js:212)
at Function.entity.topologicalTravel (component.js:125)
at ExtendedClass.mergeOption (Global.js:194)
at ExtendedClass.initBase (Global.js:663)
at ExtendedClass.resetOption (Global.js:141)
at ExtendedClass.setOption (Global.js:123)
检查了package.json,确认库已经安装好了:
"echarts": "^4.7.0",
"ngx-echarts": "^4.2.2",
"@types/echarts": "^4.4.6",
option的字段也是按照官方文档来设置的。检查模块导入时,发现是NgxEchartsModule
没有导入,尝试导入:
import { NgxEchartsModule } from 'ngx-echarts';
@NgModule({
declarations: [AppComponent],
entryComponents: [],
imports: [
BrowserModule,
IonicModule.forRoot(),
AppRoutingModule,
// ...
NgxEchartsModule,
// ...
IonicStorageModule.forRoot(),
],
providers: [
// ...
],
bootstrap: [AppComponent],
})
export class AppModule {}
重新编译程序恢复正常。