2

我在 Ionic2(v2.0.0) 项目中使用了 angular2-highcharts(v0.4.1) 组件。

当我运行我的页面时,我有一个来自 highcharts 的错误 7。

我尝试在我的角度组件上添加此代码,但没有成功...

import * as Highcharts from 'highcharts';
import * as HighchartsMore from 'highcharts/highcharts-more.js';
HighchartsMore(Highcharts);

和这个...

declare var require: any;
const Highcharts = require('../../../node_modules/highcharts/highstock.src');
const HighchartsMore = require('../../../node_modules/highcharts/highcharts-more.js');
HighchartsMore(Highcharts);

有人向这个模块添加了一些组件吗?或者知道一些图书馆在angular2上使用highcharts?


离子信息:

Cordova CLI: 6.5.0
Ionic Framework Version: 2.0.0
Ionic CLI Version: 2.2.1
Ionic App Lib Version: 2.2.0
Ionic App Scripts Version: 1.0.0
ios-deploy version: Not installed
ios-sim version: Not installed
OS: Windows 10
Node Version: v4.1.0
Xcode version: Not installed
4

1 回答 1

2

我让它像这样工作(我使用来自 npm 的 vanilla highcharts,而不是 angular2-highcharts,但是!):

import * as HighchartsMore from 'highcharts/highcharts-more';
import Highcharts from 'highcharts';

在构造函数中:

HighchartsMore(Highcharts);

希望这可以帮助!

于 2017-07-11T12:47:14.913 回答