javascript - 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"
是"category" | "indexed" | "log" | "timeseries"
x 轴类型的 const 类型之一。
const options = {
axis: {
x: {
type: "category" as const,
},
},
};
推荐阅读
- ios - Swift - 摇动手势会关闭子视图控制器
- laravel-5 - Laravel 5.6 CSRF 令牌未验证/检查
- c# - 在 Vb.net 中使用泛型
- bash - bash: (HOSTNAME) : command not found [使用 1 个主节点和 2 个从节点设置 Hadoop 集群]
- javascript - 递归承诺在调用时不会继续阻塞
- php - 后台 PHP 脚本被 Heroku 终止
- javascript - Google 如何隐藏工作表的 DOM
- html - 为什么微调器会奇怪地移动?
- hibernate - 在 grails / Hibernate 标准中使用 createAlias
- node.js - 在 Node.js 上的 Redis 消息中获取通道名称