【问题标题】:how can i use correctly the functions which have been already developed in javascript into an application in angular 4?我怎样才能正确使用已经在 javascript 中开发的功能到 Angular 4 中的应用程序中?
【发布时间】:2018-05-11 07:58:29
【问题描述】:

我正在用 Angular 4 开发一个应用程序网络。否则,还有另一个用 javascript 开发的应用程序,我必须使用已经在应用程序 Javascript 中为我在 ang4 中的应用程序创建的 D3JS 函数。我已经导入并调用了这些函数,但在测试时出现错误:ERROR TypeError: Cannot read property 'min' of undefined。实际上,min 是变量 d3 的函数,它是 类 D3JS 的实例,因此 d3 可以使用 scaleLinear、axisLeft 等方法 所以这里是图片:

in function test hello,it calls the function draw_cpuLoadMonitorChart that has been exported from the JavaScript file

the function draw_cpuLoadMonitorChart and d3 that i exported to use

the error that i got when i cliked the button Try It

file html

【问题讨论】:

  • 截图几乎没用。您需要编写一个有效的 sn-p。 stackblitz.com

标签: javascript angular d3.js import


【解决方案1】:

我没有测试过这个特定的包,但你正在寻找的是 D3.js 的类型:

https://www.npmjs.com/package/@types/d3

将此类型定义添加到您的项目中,您应该一切顺利。

https://angular.io/guide/typescript-configuration#installable-typings-files

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-06
    • 2022-11-14
    • 2020-09-25
    • 2015-07-30
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多