我正在尝试在延迟加载的模块中使用路由,但它不起作用。
这是我的应用程序模块路由。
export const routes: Routes = [
{
path: '',
component: DefaultLayoutComponent,
data: {
title: 'Home'
},
children: [
{
path: 'holiday',
loadChildren: './holiday/holiday.module#HolidayModule'
}
]
},
{
path:"**",
component:P404Component
}
];
这是延迟加载模块的routingmodule。
const routes: Routes = [
{
path: '', children: [
{ path: '', component: HolidayBookingComponent },
{ path: ':id', component: HolidayBookingComponent },
{ path: 'booking', component: HolidayBookingComponent },
{ path: 'review', component: HolidayReviewComponent }
]
},
];
我可以导航到
http://localhost:4200
和
http://localhost:4200/holiday
正确地。
但当我试着
http://localhost:4200/holiday/1
它在控制台中抛出404。
GET http://localhost:4200/holiday/runtime.js net::ERR_ABORTED 404 (Not Found)
我从上个星期开始就面临这个问题,而且找不到任何解决办法。
有人能帮忙吗?
这些是package.json中的依赖项,以备需要。
"@angular/cli": "^6.2.6",
"@angular/router": "^6.1.10",
"@angular/core": "^6.1.10",