1

我刚刚将我的项目从 Angular 2.4.7 和 Angular CLI 1.0.0-beta.31 升级到 Angular 4.0.0 和 Angular CLI 1.0.0。自升级以来,我收到以下错误:

font-awesome.min.css Failed to load resource: the server responded with a status of 404 (Not Found)
material-icons.css Failed to load resource: the server responded with a status of 404 (Not Found)
global-styles.css Failed to load resource: the server responded with a status of 404 (Not Found)
hammer.js Failed to load resource: the server responded with a status of 404 (Not Found)

这些与下面我的 index.html 中的脚本引用有关。自升级以来我没有更改结构,有人知道我为什么会收到这些错误吗?

索引.html

<!doctype html>
<html>
<head>
  <meta charset="utf-8">
  <title>Tellurium Platform</title>
  <base href="/">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="icon" type="image/x-icon" href="favicon.ico">  
  <link rel="stylesheet" href="./app/library/css/font-awesome.min.css">  
  <link rel="stylesheet" href="./global-styles.css">
  <link rel="stylesheet" href="./app/library/css/material-icons.css">

  <link href="https://fonts.googleapis.com/icon?family=Material+Icons"
      rel="stylesheet">
  <!--For Material 2 slider elements-->
  <script src="./app/library/js/hammer.js"></script>
</head>
<body class="canvas">
  <app-root>Loading...</app-root>
</body>
</html>
4

2 回答 2

2

将您的依赖项移动到.angular-cli.json像这样的脚本下的文件中

 "scripts": [
        ....,
        "./app/library/js/hammer.js"
      ],

从最新的 angulae cli 中,您必须在 angular-cli.json 文件中的脚本和样式标签下添加所有外部文件(css 和 js)

于 2017-03-25T07:09:54.103 回答
1

看看这个官方发布说明文件夹结构发生了变化,你应该将路径更改为

<link rel="stylesheet" href="./src/app/library/css/font-awesome.min.css">  
  <link rel="stylesheet" href="./global-styles.css">
  <link rel="stylesheet" href="./src/app/library/css/material-icons.css">
于 2017-03-25T07:08:21.203 回答