【发布时间】:2021-12-31 08:31:06
【问题描述】:
尝试使用 Angular 11 创建 Web 应用程序时,我发现路由存在问题: 当我从初始路线导航时(
{ path: '', component: HomeComponent }
) 到另一条路线一切都按预期工作,但是当我尝试从另一条路线导航网站时,路由器会将我重定向到初始路线。 我无法从我的网络应用程序(“”除外)向其他人发送链接,因为路由器重定向到“”(主)路由。
例子:
const routes : Routes = [
{ path: '', component: HomeComponent },
{ path: 'product/:id', component: ProductComponent }
];
从 https://localhost:4200,当我访问 https://localhost:4200/product/14 工作正常, 但是当我尝试直接访问 https://localhost:4200/product/14 时,我将被重定向到 https://localhost:4200
如何配置我的 Angular 应用程序以接受任何初始路由?
【问题讨论】:
标签: angular routes seo angular11