使用webpack时如何包括highcharts导出模块?

时间:2019-04-01 11:48:15

标签: javascript webpack highcharts

代替<script src="http://code.highcharts.com/modules/exporting.js"></script>

使用webpack时如何将其添加为依赖项?在某些模块下可以使用吗?

1 个答案:

答案 0 :(得分:1)

您需要导入并初始化模块:

import Highcharts from 'highcharts';
import exporting from 'highcharts/modules/exporting';

exporting(Highcharts);

或使用要求:

import Highcharts from 'highcharts'
require("highcharts/modules/exporting")(Highcharts);

实时演示:https://stackblitz.com/edit/react-tepuf4?file=index.js

文档:https://www.highcharts.com/docs/getting-started/install-from-npm