【发布时间】:2018-07-19 13:21:57
【问题描述】:
我在一个 Angular 项目中工作,我必须在其中集成 D3JS,我使用了
npm install d3
并且工作正常。 我需要在 js 文件中使用一个函数。我按照一些步骤导入它,但仍然出现错误,这是我所做的: 我把js文件放在node模块中。 然后我在 angular.json 文件中添加了这样的路径:
"scripts": [
"node_modules/jquery/dist/jquery.min.js",
"node_modules/materialize-css/dist/js/materialize.min.js",
"node_modules/d3/labeler.js"
]
在导入时我使用了这个脚本:
import * as labeler from 'labeler.js';
然后我添加这个声明:
declare var labeler: any;
最后我想以这种方式使用我在 labeler.js 中开发的函数 labeler:
d3.labeler()
我得到了这个错误:
[WDS] Warnings while compiling. client:147
./node_modules/labeler.js
4:16-26 "export 'labeler' (imported as 'd3') was not found in 'd3' client:153
./src/app/components/init-map-markers/init-map-markers.component.ts
916:8-18 "export 'labeler' (imported as 'd3') was not found in 'd3'
有没有人知道如何以正确的方式做到这一点?谢谢
【问题讨论】:
标签: javascript d3.js angular6