在我的 angular 2 项目中使用外部 JS 库 [英] using external JS libraries in my angular 2 project

查看:29
本文介绍了在我的 angular 2 项目中使用外部 JS 库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在我的 angular 2 项目中使用 这个 JS 库 >

这个问题可能与我重复,但没有答案对我有用

我试图将库作为脚本标签包含在我的 index.html 页面中

<块引用>

总是看不到http://localhost:8100/PrayTimes.js 文件是不存在

我也在上面写了这段代码

声明 var PrayTimes:any;

我试图在我的构造函数中使用它,但出现此错误

<块引用>

未定义祈祷时间

解决方案

将所有 javascript、外部 css、图像等放在 src/assets

(将被编译为build/assets)

在您的 index.html 中:<script src="assets/yourJavascript.js"></script>

然后你就可以像你描述的那样使用它.(声明 var PrayTimes: any;)

I need to use this JS library in my angular 2 project

this question may be duplicate with me , but no answer worked for me

I tried to include the library as script tag in my index.html page

It always does not see it http://localhost:8100/PrayTimes.js file is not exist

also I wrote this code above

declare var PrayTimes:any;

I tried to use it in my constructor , but I am getting this error

PrayTimes is not defined

解决方案

Place all javascript, external css, images etc. in src/assets

(will be compiled to build/assets)

In your index.html: <script src="assets/yourJavascript.js"></script>

Then you can just use it like you describe. (declare var PrayTimes: any;)

这篇关于在我的 angular 2 项目中使用外部 JS 库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆