我正在一个Angular项目中工作,需要将D3JS集成进来。我已经使用了
npm install d3
并且它正在正常工作。 我需要在js文件中使用一个函数。我按照一些步骤导入它,但仍然出现错误,这是我所做的: 我将js文件放在节点模块中。 然后我在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中开发的函数标记器,以以下方式进行:
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'
有没有人知道如何以正确的方式进行IT技术方面的工作?谢谢。