为什么 Angular 17 路由无法识别路由路径中的“大写字母”?

问题描述 投票:0回答:1

在下面的路由路径中的app-routing.module.ts中:

    const routes: Routes = [
    {path: '', redirectTo: 'home', pathMatch: 'full' },
    {path:'home',component: SelectComponent},
    {path: 'myForm', component: FormComponentComponent}
    ];

路径 -

{path: 'myForm', component: FormComponentComponent}
不起作用,但如果您将 'myForm' 更改为 'myform',路线将按预期工作。 为什么资本的存在阻碍了运作的路线?

尝试:'localhost:4200/myForm'它不起作用,而'localhost:4200/myform'它工作完美!!

angular routes
1个回答
0
投票

DefaultUrlSerializer
区分大小写。

如果您想要一个不区分大小写的序列化器,您必须实现并提供您自己的

UrlSerializer

© www.soinside.com 2019 - 2024. All rights reserved.