【发布时间】:2023-03-31 20:36:01
【问题描述】:
Routerlink url 不应更改为默认 url..
当我使用 RouterModule.forRoot(appRoutes, { useHash: true });它工作正常.. 但我改为 useHash = false,它不工作
在 html 中我使用了这个代码:
<a routerLink="/applicationredirect" [queryParams]="{appId: recentMenu.applicationId}">{{recentMenu.applicationMasterName}} - {{recentMenu.applicationCode}}</a>
路由页面:
const appRoutes: Routes = [
.....
{
path: 'applicationredirect', component: ApplicationRedirectComponent,
},
{
path: 'home', component: HomeComponent,
}
...
// otherwise redirect to home
{ path: '**', redirectTo: 'home' }
];
const StartupRouting = RouterModule.forRoot(appRoutes, { useHash: false });
当我在新标签页中打开时,
首先我得到了,
localhost:4200/applicationredirect?appId=1084518
然后变成这个,
localhost:4200#/home
我终于得到了这个默认页面
localhost:4200/home#/home
我希望 (localhost:4200/applicationredirect?appId=1084518) 网址打开..
【问题讨论】:
标签: angular angular-routerlink