我使用 ES6、Babel 和 webpack 堆栈。
我已经通过 npm 安装了 highcharts(我更喜欢使用官方的 highcharts npm repo):
npm install highcharts-release --save
但是,常规导入 (ES6) 无法按预期工作:
import highcharts from 'highcharts';
如何通过 webpack import 导入 Highcharts? 您可以发布一个 webpack.config.js 示例(或其他配置插件的方式)吗?
谢谢。
编辑
错误是:
Uncaught Error: Cannot find module "highcharts" webpackMissingModule @ review-chart.js:2(anonymous function) ....
最佳答案
试试这个:
npm 安装 highcharts
我遇到这种方法的问题是在 highcharts 中使用其他模块,例如 highcharts-more、map 等,为了克服这个问题,我导入了 highcharts 和其他所需的模块,如下所示:
import highcharts from 'highcharts';
import highchartsMore from 'highcharts-more';
highchartsMore(highcharts);
关于javascript - 如何使用 webpack 和 babel 导入 highcharts,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33241358/