我正在使用 @RouteConfig 进行导航,路由配置如下:
@RouteConfig([
{ path: '/calendar', name: 'Calendar', component: CalendarComponent }]}
当我使用路由链接时,CarouselComponent 被加载。
<a [routerLink]="['Calendar']">Calendar</a>
URL路由到http://localhost:60708/calendar
但是,当我想要直接通过在地址栏中输入URL或点击F5(刷新页面)访问页面后再点击路由链接来访问URL http://localhost:60708/calendar 时,页面不再显示。
为什么会发生这种情况?如何使用URL路径加载组件?
HashLocationStrategy
。参见:https://dev59.com/AFsW5IYBdhLWcg3w0aHM 和 https://angular.io/docs/ts/latest/api/router/HashLocationStrategy-class.html - Langley