如何在 React 应用程序中导入 highcharts 子模块

Dan*_*ton 1 javascript charts highcharts npm reactjs

我一直在使用react-jsx-highcharts模块,将Highcharts集成到我的 React 应用程序中。

效果很好。现在我想包括boost 模块。我不知道该怎么做。我尝试简单地添加,import 'highcharts/modules/boost'但这似乎不起作用。

有谁知道如何解决这个问题?

Dan*_*ton 5

这是highcharts模块的一个特性(不是react-jsx-highcharts),并在其文档中进行了解释:

var Highcharts = require('highcharts');
require('highcharts/modules/boost')(Highcharts);
Run Code Online (Sandbox Code Playgroud)

或者,您可以import像这样使用:

import Highcharts from 'highcharts';
import boost from 'highcharts/modules/boost';
boost(Highcharts);
Run Code Online (Sandbox Code Playgroud)