mar*_*lph 10 node.js typescript angular-cli angular
在角度2中,我可以像这样在index.html中添加它们:
<link rel="stylesheet" href="css/mycss.css">
Run Code Online (Sandbox Code Playgroud)
但是在角度4中,必须将它添加到样式和脚本数组部分中的angular-cli.json文件中.
在我的情况下,它们似乎根本没有装载.没错,但是当我在浏览器中查看应用程序时,我知道样式没有加载.当我将样式和js添加到index.html文件时,它也没有被加载,我在控制台中得到了404.
我该如何解决?下面是我的Angular cli版本:@ angular/cli:1.0.2节点:6.9.2
小智 14
如果你正在使用angular cli然后转到你的.angular-cli.json然后你可以得到"样式":[]以及"脚本":[] 这些你可以添加你的css文件和js文件
"styles": [
yourfirst-css-file , //comma (,)is important
your-second-css-file
],
Run Code Online (Sandbox Code Playgroud)
例如:-
"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"
],
Run Code Online (Sandbox Code Playgroud)
和404错误意味着找不到该文件.尝试并附加完整的"url"文件夹(src).
归档时间: |
|
查看次数: |
9399 次 |
最近记录: |