首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >模块未找到错误无法解析angular 7

模块未找到错误无法解析angular 7
EN

Stack Overflow用户
提问于 2019-03-27 17:33:24
回答 1查看 2.8K关注 0票数 2

我正在尝试将交互式d3气泡图与angular 7集成在一起,但是在构建我的示例应用程序时,我总是得到

代码语言:javascript
复制
module not found error can't resolve 'd3' in '.../Angular_Example/angular-d3-graph-example-master/src/app/d3'

请帮帮我,谢谢

代码语言:javascript
复制
import { Node, Link, ForceDirectedGraph } from './models';
import * as d3 from 'd3';

@Injectable()
export class D3Service {
  constructor() { }


  applyZoomableBehaviour(svgElement, containerElement) {
    let svg, container, zoomed, zoom;

    svg = d3.select(svgElement);
    container = d3.select(containerElement);

    zoomed = () => {

  }

  applyDraggableBehaviour(element, node: Node, graph: ForceDirectedGraph) {

    }


  }


  getForceDirectedGraph(nodes: Node[], links: Link[], options: { width, height }) {
    const sg = new ForceDirectedGraph(nodes, links, options);
    return sg;
  }
}
EN

回答 1

Stack Overflow用户

发布于 2019-10-01 22:54:52

考虑到@mayuringole的反馈,步骤如下:

代码语言:javascript
复制
npm install d3 --save
npm install @types/d3 --save

这为我解决了这个问题。在我的示例中,我尝试通过<script>标记使用d3库,但并非所有组件都被识别

通过npm + import * as d3 from "d3";安装模块,运行正常

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55373846

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档