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

问题描述 投票:0回答:1

而不是<script src="http://code.highcharts.com/modules/exporting.js"></script>

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

javascript webpack highcharts
1个回答
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

© www.soinside.com 2019 - 2024. All rights reserved.