在角度4:ReferenceError:在模块

时间:2017-12-28 11:02:07

标签: javascript angular d3.js nvd3.js

我想在我的app.module中以角度4导入它。而不是将其插入我的索引文件。

In app.module.ts -> 

import d3 from "d3";
console.log(d3) // shows that D3 is successfully imported

import nvd3 from "nvd3";

页面抛出错误:

  

ReferenceError:未定义d3

另外,我在package.json

中添加了这些依赖项

1 个答案:

答案 0 :(得分:0)

只需在你的模块中使用,

import 'd3';
import 'nvd3';

并在顶部的组件中声明d3

declare var d3: any;