You are expecting more magic from this component than it could provide :)
The requests are going to HTTP server, not directly to the <app-router>
component. You are using HTML5 pushState
way of handling routes. That said, when you specify /new
as new path, the component shows the desired import and substitutes the location.href
with http://youserver/new
. On the other hand, when you press F5
, the browser is being redirected to http://youserver/new
. Sounds like different actions, right?
So, the request to http://youserver/new
is being handled by your web server and since there is no such page, you get 404
.
You have two options here:
- teach your HTTP server to handle
/new
as your_router_page.html
with mod_rewrite
or like;
- specify the proper path in
<app-route>
s.
The component-way (IMHO) is to specify the proper path:
<app-route path="/my-router.html?/dash"></app-route>
Or even better get stuck to hash-like navigation, since it works out of the box and requires no specific route handling at all. The pushState
is more like to handle redirects to outside of the current component handler.
Hope it helps.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…