角2.0路由器不工作重装浏览器 [英] Angular 2.0 router not working on reloading the browser
问题描述
我使用的角度2.0.0 alpha.30版本。当重定向到一个不同的路线,然后刷新浏览器,它的表现不能得到/路由。
I am using Angular 2.0.0-alpha.30 version. When redirect to a different route, then refresh the browser , its showing Cannot GET /route.
您可以帮我搞清楚为什么会发生错误。
Can you help me with figuring why this error happened.
推荐答案
我认为你看到的错误是因为你正在请求的http://本地主机/路由的不存在。你需要确保你的服务器映射到主index.html页面的所有请求。
I think the error you are seeing is because your are requesting http://localhost/route which doesn't exist. You need to make sure that your server will map all requests to your main index.html page.
由于角2默认使用HTML5的路由,而不是在URL的末尾使用哈希值,刷新页面看起来像一个不同的资源的请求。
As Angular 2 uses html5 routing by default rather than using hashes at the end of the url, refreshing the page looks like a request for a different resource.
这篇关于角2.0路由器不工作重装浏览器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!