billboard.js:“axis.x.type”的类型在这些类型之间不兼容

问题描述

axis: {
    x: {
      type: "category"
    }
  },

我有错误

The types of 'axis.x.type' are incompatible between these types.
    Type 'string' is not assignable to type '"category" | "indexed" | "log" | "timeseries"'

我找不到如何用另一种方式初始化类型。你能帮我吗?

解决方法

Cast category as const to notify ts "category" 是 x 轴类型中 "category" | "indexed" | "log" | "timeseries" 的 const 类型之一。

const options = {
  axis: {
    x: {
      type: "category" as const,},};

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...