我正在尝试在angular 6 typescript模块文件app.module.ts
中导入highcharts注释。我尝试了下面的代码,但它显示了一个错误
"找不到模块‘highcharts/module/annotations’的声明文件">
但annotations.js
文件位于同一路径,并且在控制台中显示错误
"错误类型错误:chart.addAnnotation不是函数"。
以前有人尝试过吗?
代码:
import { ChartModule } from 'angular2-highcharts';
import { AnnotationsModule } from 'highcharts/modules/annotations';
import * as Highcharts from 'highcharts';
尝试以这种方式导入模块:
import * as AnnotationsModule from "highcharts/modules/annotations"
并初始化它:
AnnotationsModule(Highcharts);
或使用要求:
require('highcharts/modules/exporting')(Highcharts);
请查看我推荐给您的带有highcharts angular官方包装的演示。
演示:https://codesandbox.io/s/329llv6wj1