刷新子路由时出错,Angular 4

时间:2017-07-17 09:23:24

标签: angular angular-routing

我在index.html中使用PathLocationStrategy和<base href="/">。 当我进入一个像产品细节的孩子路线,如果我尝试刷新页面,我得到错误:无法匹配任何路线,如果我使用浏览器返回和转发。 我是否需要切换到HashLocationStrategy来处理刷新?

这是儿童路线。

import { Route } from '@angular/router';
import { CustomerDetailComponent } from './index';

export const CustomerDetailRoutes: Route[] = [
  {
    path: 'customer-detail/:code',
    component: CustomerDetailComponent
  },
];

这是父路线

import { DashboardComponent } from './index';

export const DashboardRoutes: Route[] = [
    {
      path: 'dashboard',
      component: DashboardComponent,
      children: [
        ...HomeRoutes,
        ...HotelRoutes,
        ...UserDetailRoutes,
        ...TicketTypeRoutes,
        ...TicketBlockRoutes,
        ...TransitCertificateRoutes,
        ...TemplateDetailRoutes,
        ...DepositReceiptRoutes,
        ...TemplateRoutes,
        ...LicensePlateDetailRoutes,
        ...DepositReceiptDetailRoutes,
        ...LicensePlatesRoutes,
        ...CustomerDetailRoutes,

      ]
    }
];

0 个答案:

没有答案