小编Mah*_*uvo的帖子

错误 TS2322:类型“string”无法分配给类型“keyof ChartTypeRegistry”

home.component.ts

global: boolean = false;
country!: string;
data: GlobalData;
dailyData: any[] = [];
countries: any[] = [];
lineChartData: any[] = [
  {
    data: [65, 64, 33, 44],
    label: 'Temp label'
  }
];
lineChartType = "line";
lineChartLabels: any[] = [
  'label01', 'label02', 'label03'
];
barChartData: any[] = [
  {
      data: [65, 76, 33],
      label: 'Label'
  }
];
Run Code Online (Sandbox Code Playgroud)

home.component.html

<canvas baseChart
    [chartType] = "lineChartType"
    [datasets] = "lineChartData"
    [labels] = "lineChartLabels"
>
</canvas>
Run Code Online (Sandbox Code Playgroud)

错误:

类型“string”不可分配给类型“keyof ChartTypeRegistry”

错误行:

[chartType] = "lineChartType"
Run Code Online (Sandbox Code Playgroud)

错误发生在 home.component.html

我需要一个解决方案。尝试在谷歌上找到解决方案,但我找不到。

typescript chart.js ng2-charts angular

8
推荐指数
1
解决办法
1万
查看次数

标签 统计

angular ×1

chart.js ×1

ng2-charts ×1

typescript ×1