我正面临这个错误 highcharts.js:formatted:1 Uncaught ReferenceError: Highcharts is not defined 谁能帮我这个

时间:2021-04-28 16:00:01

标签: javascript reactjs highcharts

我正在一个名为 componentDidMount 的函数中创建 highcharts,代码可以在下面找到。

componentDidMount() {
    const p = this.props
    const highcharts = p.highcharts || Highcharts;
    const constructorType = p.constructorType || 'chart';
    // Create chart
    this.chart = highcharts[constructorType](this.container.current, Object.assign({}, p.options));
  }

我不明白为什么我会收到错误

highcharts.js:formatted:1 Uncaught ReferenceError: Highcharts is not defined
    at e.drawEmpty (highcharts.js:formatted:1)
    at e.redrawPoints (highcharts.js:formatted:1)
    at e.render (highcharts.js:formatted:1)
    at highcharts.js:formatted:1
    at Array.forEach (<anonymous>)
    at B.renderSeries (highcharts.js:formatted:1)
    at B.render (highcharts.js:formatted:1)
    at B.firstRender (highcharts.js:formatted:1)
    at B.<anonymous> (highcharts.js:formatted:1)
    at g.fireEvent (highcharts.js:formatted:1)
    at B.init (highcharts.js:formatted:1)
    at B.getArgs (highcharts.js:formatted:1)
    at new B (highcharts.js:formatted:1)
    at Object.c.chart (highcharts.js:formatted:1)
    at ReactHighcharts.componentDidMount (ReactHighcharts.jsx:28)
    at ReactHighcharts.componentDidMount (highcharts.js:formatted:1)

有人能帮我找到问题吗?

1 个答案:

答案 0 :(得分:0)

错误告诉您 Highcharts 未定义

它从哪里来?您能否扩大范围

这意味着您正在使用一个从未声明过的变量。