问题描述
我需要在我的 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
also I wrote this code above
declare var PrayTimes:any;
I tried to use it in my constructor , but I am getting this error
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 库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!