首页 > 解决方案 > 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"'

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

标签: javascripttypescriptbillboard.jses6-modules

解决方案


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

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

推荐阅读