問題角2頁路由錯誤
爲什麼不能我我的路由頁面上刷新沒有得到錯誤?
問題
我在<navigation>
指令有一個onSelect
並嘗試加載我PageComponent
到<router-outlet>
。這實際上有效,您可以看到我的頁面在您點擊測試導航鏈接時被加載。
在我的真實代碼中,如果我點擊它,網址將變爲http://localhost:3000/page/10
(10只是一些id,不相關)。如果我現在刷新頁面上,我會得到錯誤。
好像它搜索在錯誤的道路上/page/node_modules
的.js文件而不是/node_modules/
錯誤
GET http://localhost:3000/page/style.css
GET http://localhost:3000/page/vendor.js
GET http://localhost:3000/page/node_modules/es6-shim/es6-shim.min.js
GET http://localhost:3000/page/node_modules/systemjs/dist/system-polyfills.js
GET http://localhost:3000/page/node_modules/angular2/bundles/angular2-polyfills.js
GET http://localhost:3000/page/node_modules/systemjs/dist/system.src.js
GET http://localhost:3000/page/node_modules/angular2/bundles/angular2.dev.js
GET http://localhost:3000/page/node_modules/rxjs/bundles/Rx.js
GET http://localhost:3000/page/node_modules/angular2/bundles/http.dev.js
GET http://localhost:3000/page/node_modules/angular2/bundles/router.dev.js
Uncaught ReferenceError: System is not defined
設置
我試圖把我的例子了上plunkr。但我想你真的不能真正刷新那裏來準確地測試我的錯誤。
https://embed.plnkr.co/7P21IbHr8EOuUW7NjmFS/
您的服務器是否配置爲支持HTML5 pushState? http://stackoverflow.com/questions/31415052/angular-2-0-router-not-working-on-reloading-the-browser –
@GünterZöchbauerty,很好的鏈接。我有點向錯誤的方向搜索。我可以使用標籤來暫時修復它,這可能不是最好的方法。我想我會盡快嘗試它服務器端立即離開我的本地主機設置:) – NDY