简体   繁体   English

在我的angular4应用程序中添加js文件

[英]Add js file in my angular4 application

I would like to use in one of my components this effect: 我想在我的组件之一中使用这种效果:

https://codepen.io/linrock/pen/Amdhr https://codepen.io/linrock/pen/Amdhr

my first approach was to try to translate the javascript to typescript, but then I gave up and I decided to copy the js file that you can find in the codepen and try to import it in my application. 我的第一种方法是尝试将javascript转换为打字稿,但是后来我放弃了,决定复制可在codepen中找到的js文件,然后尝试将其导入我的应用程序。

Then, I copied the file in src/app/scripts/confetti.js and then I tried to import it in my index.html 然后,我将文件复制到src / app / scripts / confetti.js中,然后尝试将其导入到index.html中

<script src="scripts/confetti.js"></script>

But I get that the file confetti.js is not found when I run my app. 但是我发现运行我的应用程序时找不到confetti.js文件。

Do you know what I am doing wrong? 你知道我在做什么错吗?

you need to copy your js file to "src/resources/js/" and then include it in your .angular-cli.json 您需要将js文件复制到“ src / resources / js /”,然后将其包含在.angular-cli.json中

"scripts": [
        "resources/js/confetti.js"
           ],

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM