ngx-echarts从2.0升级到8.0后报错
不能将类型“string”分配给类型“”line” | “bar” | “scatter” | “pie” | “radar” | “map” | “tree” | “treemap” | “graph” | “gauge” | “funnel” | “parallel” | “sankey” | “boxplot” | “candlestick” | “effectScatter” | … 5 more … | “custom””。ts(2322)
echarts.d.ts(9427, 5): 所需类型来自属性 “type”,在此处的 “SeriesOption$1” 类型上声明该属性

解决办法

你需要强制转换

  1. //导入一个类型
  2. export type seriesType = "line" | "bar" ;
  3. //将报错的类型又string改为seriesType 即可
  4. chartType:seriesType ='line' as seriesType;//图表样式 line折线图 bar-柱状图