我试图在Angular CLI 7中使用dygraphs,但导入无法正常工作。我首先使用npm install --save dygraphs
安装它,在我的导入中我写了import { Dygraph } from 'dygraphs';
,但TSLint中的错误仍然说File '/home/[...]/node_modules/@types/dygraphs/index.d.ts' is not a module.ts(2306)
。
chart.js
导入会显示相同的错误消息,但在此处,它可以正常工作。所有图表都正确显示。
此外,编译器说error TS2305: Module '"dygraphs"' has no exported member 'Dygraph'.
,这意味着模块导入正常,但找不到成员?
在Web控制台中,错误消息是RROR Error: Uncaught (in promise): TypeError: dygraphs__WEBPACK_IMPORTED_MODULE_6__.Dygraph is not a constructor
。我想创建一个这样的图形:
private config = [
[1, 2, 3],
[4, 5, 6],
];
g = new Dygraph(document.getElementById("div_g"), this.config,
{
drawPoints: true,
showRoller: true,
valueRange: [0.0, 1.2],
labels: ['Time', 'Random']
});
谢谢你的协助。