gpt4 book ai didi

javascript - 使用延迟加载模块的路由不适用于参数

转载 作者:行者123 更新时间:2023-11-30 14:17:19 25 4
gpt4 key购买 nike

我知道网站上已经有很多关于延迟加载的讨论。我问这个问题是因为我没有找到任何适用的解决方案。

我在 Angular 6 中使用带有延迟加载的路由。

这就是我正在尝试的。在父模块中

{
path: 'holiday',
loadChildren: './holiday/holiday.module#HolidayModule'
}

在子模块中。

const routes: Routes = [
{path: '',component: HolidayBookingComponent},
{path: ':id', component: HolidayBookingComponent}
];

在导航 "localhost:4200/holiday" 时,它正确地重定向到 HolidayBookingComponent

但是当我导航到 "localhost:4200/holiday/3" 时,我得到了

GET http://localhost:4200/holiday/runtime.js net::ERR_ABORTED 404 (Not Found)

最佳答案

试试

const routes: Routes = [
{path: '',
children :[
{path: '',component: HolidayBookingComponent,
{path: ':id', component: HolidayBookingComponent}
]
},

];

希望对您有所帮助!

在这里工作https://stackblitz.com/edit/angular-yuirrk

enter image description here

关于javascript - 使用延迟加载模块的路由不适用于参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53362498/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com