2017-03-25 71 views
1

我剛從Angular 2.4.7和Angular CLI 1.0.0-beta.31將我的項目升級到Angular 4.0.0和Angular CLI 1.0.0。自升級以來,我收到以下錯誤:升級Angular獲取404未找到索引中的腳本

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下面的腳本引用。自升級以來我沒有更改結構,有誰知道我爲什麼會遇到這些錯誤?

的Index.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> 

回答

2

將您dependencie到.angular-cli.json下的文件這樣的腳本

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

從你要添加的所有外部文件(CSS和JS)腳本和風格標籤下的角cli.json文件

1

看一看這位官員release notes文件夾結構發生變化,你應該改變路徑

<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"> 
+0

謝謝,但你可以看到有最新的angulae CLI是一個錯誤使用與index.html位於同一目錄中的global-styles-css。 Pardeep答案是正確的,依賴關係現在必須是angular-cli.json –

相關問題