如何添加自定义css和jsangular4
在angular2中,我可以将它们添加到index.html中,如下所示:
<link rel="stylesheet" href="css/mycss.css">
但是在angular 4中,它必须被添加到样式和脚本数组部分中的angular-cli.json文件中。
在我的情况下,他们似乎并没有被加载。 没有错误,但当我在浏览器中查看应用程序,我知道样式没有加载。 当我将样式和js添加到index.html文件时,它也不会被加载,我在控制台中得到一个404。
我该如何解决? 以下是我的Angular cli版本:@ angular / cli:1.0.2 Node:6.9.2
如果你正在使用angular度cli然后去你的.angular-cli.json然后你可以得到“样式”:[]以及“脚本”:[]里面你可以添加你的CSS文件和js文件
"styles": [ yourfirst-css-file , //comma (,)is important your-second-css-file ],
例如:-
"styles": [ "styles.css", "../node_modules/bootstrap/dist/css/bootstrap.min.css" ], "scripts": [ "../node_modules/jquery/dist/jquery.js", "../node_modules/tether/dist/js/tether.js", "../node_modules/bootstrap/dist/js/bootstrap.js" ],
和404错误意味着该文件没有found.Try并追加完整的“url”文件夹(src)。