【发布时间】:2021-03-16 09:14:54
【问题描述】:
我在路由模块中有这样定义的路由:
{ path: 'warning/:type', component: WarningPageComponent }
当应用想要导航到警告页面时,会进行此调用:
const navigationExtras: NavigationExtras = {
queryParamsHandling: 'preserve',
queryParams: { errorCode: '12345'}
};
return this.router.navigate(['/warning/default'],navigationExtras);
在WarningPageComponent 中,参数读取如下ngOnInit():
const params = this.route.snapshot.paramMap;
console.log('ERR warning page' + JSON.stringify(params));
const errorCode = params.get('errorCode') ?? undefined;
const type = params.get('type') ?? undefined;
现在的问题是paramMap 中只有type 而errorCode 中没有。这里有什么问题?我也试过queryParamsHandling: 'preserve'
Angular 8.2.14
我没有找到解决方案:
【问题讨论】: