在浏览器上重载Angular js 2嵌套路由组件未加载



我有一个routeconfig,它在父组件下创建了一个子路由,我注意到当我使用路由链接(通过单击routelink设置为子路由的href标签)访问嵌套路由时,一切都会发生,但当我在子路由上刷新浏览器或直接在浏览器中输入子路由链接时,它无法加载子组件,即仅加载父组件。

有问题的url-localhost:3000/#/dashboard/breservation

我的路线配置低于

主应用程序组件路由到父组件(仪表板)

@RouteConfig([
  ...
  { path: '/dashboard/...', name: 'Dashboard', component: Dashboard}, 
  ...
])
Dashboard component creates child route
@RouteConfig([
  { path: '/reservation', name: 'Reservation', component: Reservation , useAsDefault: true},
]);

我遇到了同样的问题,但我通过在index.html<head>中使用此代码解决了问题。这是APP_BASE_HREF 的一个错误

<base href="/">
<!-- Set the base href -->
<script>document.write('<base href="'+ document.location +'"/>');</script>

最新更新