我無法讓我的角應用在本地運行。我收到一個錯誤,我的interview.js和angular.js沒有找到。另外,當我從dev控制檯打開時,angular.js文件中未定義角度。我無法讓我的Angular應用在本地運行
這裏是我的目錄結構:
mock
public
index.html
src
services
interview.js
vendor
angular.js
這裏是我的index.html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<title>Interview Practice</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="../vendor/angular.js" type="text/javascript"></script>
</head>
<body ng-app="interviewapp">
hello world!
<script src="../src/interview.js" type="text/javascript"></script>
</body>
</html>
這裏是我的interview.js
angular.module("interviewapp", []);
console.log("does this work");
我使用的HTTP服務器啓動應用程序。
Starting up http-server, serving ./public
Available on:
http://10.66.87.184:8080
http://192.168.56.1:8080
http://127.0.0.1:8080
去到本地主機,或任何所列的HTTPS的,這是我得到的錯誤:
http://10.66.87.184:8080/vendor/angular.js Failed to load resource: the server responded with a status of 404 (Not Found)
http://10.66.87.184:8080/src/interview.js Failed to load resource: the server responded with a status of 404 (Not Found)
我該如何解決這個問題,使我的應用程序運行?
將'src'和'vendor'目錄移動到'public'目錄並從路徑的開始處移除'..'到文件例如將'src =「../ src/interview.js」'更改爲'src =「/ src/interview。js「' –
我鏈接了一個cdn for angular,並且做了你所說的src文件夾。你能告訴我爲什麼這樣工作嗎? – McFiddlyWiddly
爲你添加了一個答案和解釋 –