簡體   English   中英

找不到模塊錯誤無法解析角度7

[英]Module not found error can't resolve angular 7

我正在嘗試將交互式d3氣泡圖與angular 7集成在一起,但是在構建示例應用程序時,我總是得到

module not found error can't resolve 'd3' in '.../Angular_Example/angular-d3-graph-example-master/src/app/d3'

請幫幫我,謝謝


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;
  }
}

考慮到@mayuringole的反饋,以下是步驟:

npm install d3 --save
npm install @types/d3 --save

這為我解決了這個問題。 就我而言,我嘗試通過<script>標記使用d3庫,但並非所有組件都可以識別

通過npm + import * as d3 from "d3";安裝模塊import * as d3 from "d3"; 一切順利

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM