我收到此错误,我无法弄清楚,我错过了什么吗?

土沙

我正在关注这篇文章以使用角度图表。即使逐步遵循它,我仍然收到此错误。有人可以向我解释错误是什么以及它为什么会发生吗?

我的 app.component.ts:

import { Component } from '@angular/core';


import {
  ChartComponent,
  ApexAxisChartSeries,
  ApexChart,
  ApexXAxis,
  ApexTitleSubtitle
} from "ng-apexcharts";


export type ChartOptions = {
  series: ApexAxisChartSeries;
  chart: ApexChart;
  xaxis: ApexXAxis;
  title: ApexTitleSubtitle;
};


@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent {
  // @ViewChild("chart") chart: ChartComponent;
  public chartOptions: Partial<ChartOptions>;

  constructor() {

    this.chartOptions = {
      series: [
        {
          name: "My-series",
          data: [10, 41, 35, 51, 49, 62, 69, 91, 148]
        }
      ],
      chart: {
        height: 350,
        type: "bar"
      },
      title: {
        text: "My First Angular Chart"
      },
      xaxis: {
        categories: ["Jan", "Feb",  "Mar",  "Apr",  "May",  "Jun",  "Jul",  "Aug", "Sep"]
      }
    };

  }


  }

这是我的 app.component.html,这是发生错误的地方 在此处输入图片说明

肾上腺素

该错误表示您提供的类型与预期的类型不对应。[title] 期望类型ApexTitleSubtitle,并且您的变量是类型ApexTitleSubtitle | undefined

我想你会问有什么区别。我认为,这是由于Partial<>. 当您定义 Partial 时,您说 T 类型的每个字段都可以是可选的,因此每个字段都可以有一个值或为undefined库组件想要作为输入 aChartOptions而不是 a Partial<ChartOptions>

如果您希望它有效,只需删除部分并设置所需的属性

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

无法弄清楚为什么我在Swift iOS App Code中收到“ Class ViewController没有初始化程序”错误

类型擦除:我错过了什么吗?

我无法弄清楚在进行此MYSQL查询时犯了什么错误

无法弄清楚我的条件有什么问题

无法弄清楚为什么我收到UnboundLocalError

React无法弄清楚为什么我收到太多重新渲染错误

无法弄清楚为什么我的代码无法呈现

我似乎无法弄清楚我的错误是我的悬停无法在我的网站上正常工作

无法弄清楚我的for循环中有什么语法错误

我无法弄清楚这些错误

MYSQL错误,我似乎无法弄清楚

无法弄清楚为什么这给了我TypeError

我无法弄清楚我的Python Socket错误

我收到错误消息:[ng:areq]参数'employeeObj'不是一个函数,未定义,我无法弄清楚我错过了什么

无法弄清楚我的代码出了什么问题

Scala-使用DFS检测周期吗?我的代码有错误,我似乎无法弄清楚为什么

我的教授可以弄清楚我网站的框架吗?

即使我返回json也无法弄清楚为什么Ajax返回错误

我无法弄清楚这个查询

无法弄清楚我的路由错误来自哪里

无法弄清楚为什么我无法显示不在数组中的值的错误消息

Verilog 函数 - 无法弄清楚我的错误

excel + vba + 编译错误 AutoOpenRequiredWorkbook (myFileNameToOpen, myFilePath) 无法弄清楚为什么我会收到此错误

你能弄清楚为什么我的代码给我一个 IndexOutOfBounds 错误吗?

教授表示我错过了 2 个标签样式,但无法弄清楚是什么

我无法弄清楚这条线是做什么的

我收到一个错误,无法将 int* 转换为 int,但我无法弄清楚是什么导致了它

无法弄清楚为什么我在尝试 CSV 行数时不断收到 KeyError

无法弄清楚为什么我会收到 typeError 'unsupported operand type(s) for -: 'int' and 'str' '