Angular 2.0 路由器无法重新加载浏览器 [英] Angular 2.0 router not working on reloading the browser
本文介绍了Angular 2.0 路由器无法重新加载浏览器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用的是 Angular 2.0.0-alpha.30 版本.当重定向到不同的路由时,刷新浏览器,显示Cannot GET/route.
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://localhost/route 不存在.根据西蒙.
使用 html5 路由时,您需要将应用中的所有路由(当前为 404)映射到服务器端的 index.html.这里有一些选项供您选择:
When using html5 routing you need to map all routes in your app(currently 404) to index.html in your server side. Here are some options for you:
$live-server --entry-file=index.html`
使用 nginx:http://nginx.org/en/docs/beginners_guide.html
error_page 404 /index.html
Tomcat - web.xml 的配置.来自 Kunin 的评论
<error-page>
<error-code>404</error-code>
<location>/index.html</location>
</error-page>
这篇关于Angular 2.0 路由器无法重新加载浏览器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文