kittencup / angular2-ama-cn

angular2 随便问
692 stars 101 forks source link

使用Angular CLI 新建一個專案後放置Apache上卻有路徑問題 #207

Open JaosnHsieh opened 8 years ago

JaosnHsieh commented 8 years ago

安裝完 angular cli後 我使用 ng new myproj ng serve 會顯示正常 但伺服器是由angular cli建立,因為我想試著搬回自己的伺服器用,所以我用 ng build 之後 把dist資料夾內的檔案全部移到apache靜態伺服器下,但若是子網域的話,例如localhost/angular ,index.html內的js都會對不上正確的路徑,只有在localhost根目錄下才能運行,請問該如何修改才能在子目錄下也運行呢? 謝謝

CHORME console的錯誤訊息 http://localhost/vendor/es6-shim/es6-shim.js Failed to load resource: the server responded with a status of 404 (Not Found) http://localhost/vendor/systemjs/dist/system.src.js Failed to load resource: the server responded with a status of 404 (Not Found) http://localhost/vendor/zone.js/dist/zone.js Failed to load resource: the server responded with a status of 404 (Not Found) http://localhost/vendor/reflect-metadata/Reflect.js Failed to load resource: the server responded with a status of 404 (Not Found) http://localhost/vendor/systemjs/dist/system.src.js Failed to load resource: the server responded with a status of 404 (Not Found) http://localhost/vendor/zone.js/dist/zone.js Failed to load resource: the server responded with a status of 404 (Not Found) localhost/:19 Uncaught ReferenceError: System is not defined

index.html的原始碼 ` <!doctype html>

ScotchyScotch Loading... ``` ``` ` 圖 錯誤畫面 http://imgur.com/a/k7yIo index.html的原始碼 http://imgur.com/a/k7yIo
AngryCapricorn commented 7 years ago

将index.html中的base href修改为项目名