javascript - “未通过“highcharts”属性”constructorType="chart" 警告
问题描述
我正在开始一个项目,我想将 Highchart stockChart
react 组件改编为常规 Highchart ( chart
) 组件。我在演示中对其进行了调整,一切正常。
当我移动到我的本地项目时,我无法constructorType
从stockChart
to更改chart
,它可以编译但是当我尝试运行应用程序时出现此错误
类型错误:t[n] 不是函数
吨
C:/src/HighchartsReact.js:30
27 | const H = props.highcharts || Highcharts;
28 | const constructorType = props.constructorType || 'chart';
29 |
> 30 | if (!H) {
| ^ 31 | console.warn('The "highcharts" property was not passed.');
32 |
33 | } else if (!H[constructorType]) {
(匿名函数)
C:/src/HighchartsReact.js:52
49 | }
50 |
51 | if (!chartRef.current) {
> 52 | createChart();
| ^ 53 | } else {
54 | if (props.allowChartUpdate !== false) {
55 | if (!props.immutable && chartRef.current) {
我的本地项目运行与演示相同的依赖项,我不知道我为什么要面对这个TypeError
。根据文档,这是默认调用。
解决方案
我遇到了这个问题,因为您必须专门将主要的 Highcharts 对象传递给 HighchartsReact,如下所示:
import Highcharts from "highcharts";
return (
<HighchartsReact
highcharts={Highcharts}
options={hiChartsOptions}
/>
);
推荐阅读
- c# - 假设在编写扩展方法时实现了 ToString()
- php - 加载图像php后预加载器继续加载
- python - Python:带有 numpy 数组的属性设置器
- properties - 在系统重新启动时,为什么 Hashicorp 领事属性会更改?
- c# - 动作过滤器属性中的调用配置设置
- android - 键盘显示在 ExpandableListView android 之上
- python - 将 python 脚本(具有 __name__ == '__main__')转换为包/库
- javascript - 如何开始使用 Vuejs/Nuxtjs 应用程序中的 @jsplumb/browser-ui?
- python - 如何获取包含给定列表中句子中的单词的字典作为键和该给定列表中出现的列表
- angular - 如果表只有一行,则运行函数