我有一个带有index.html文件的angular2应用程序。我在index.html
中有这一行link rel =“stylesheet”type =“text / css”href =“styles.css”
样式表在那里,并且实际上已加载,因为它通过应用在styles.css中定义的样式来影响页面。
但是这个错误会在控制台中抛出。
无法加载资源:服务器响应状态为404 (未找到)
我有一段时间没有这个错误,并且一直以为我会稍后处理它,并认为它与旧版本的角度2有关。但是现在我在2.3.1并且错误仍然被抛出在控制台中。我该如何解决这个问题?
的index.html
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>MemberAdmin</title>
<base href="/">
<link rel="stylesheet" type="text/css" href="styles.css">
<script type="text/javascript" src="assets/IndexResources/jquery.js"></script>
<!--<link rel="stylesheet" href="http://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css" media="all">-->
<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<!--<link rel="stylesheet" type="text/css" href="assets/IndexResources/angular-calendar.css">-->
<link href="https://fonts.googleapis.com/css?family=Quicksand" rel="stylesheet">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="./assets/smalllogo.png">
</head>
<body>
<app-root>Loading...</app-root>
</body>
</html>
文件夹结构:
答案 0 :(得分:2)
由于您使用的是@angular/cli
,因此无需将css添加到索引中,只需在.angular-cli.json
文件中添加样式表的路径即可。
"styles": [
"styles.css",
"css/spinner.css",
"css/bootstrap.min.css",
"css/font-awesome.min.css"
],