Angular 角度返回url为空
在我的应用程序中,如果个人未登录,则使用返回url登录Angular 角度返回url为空,angular,Angular,在我的应用程序中,如果个人未登录,则使用返回url登录 this.user=this._session.getEmployee(); if(!this.user){ this.router.navigate(['PA/Login'], {queryParams: {returnUrl:this.url}}); } 在ngOnInit中的登录组件中,我正试图用下面的代码访问。 在costructor中,我声明了私有路由:ActivatedRoute this.url=this.ro
this.user=this._session.getEmployee();
if(!this.user){
this.router.navigate(['PA/Login'], {queryParams: {returnUrl:this.url}});
}
在ngOnInit
中的登录组件中,我正试图用下面的代码访问。
在costructor中,我声明了私有路由:ActivatedRoute
this.url=this.route.snapshot.paramMap.get('returnUrl');
这是我的路线配置
const routes: Routes = [
{path:"",redirectTo:"PA/Login",pathMatch:"full"},
{path:"PA",redirectTo:"PA/Login",pathMatch:"full"},
{path:"PA/Home",component:HomeComponent},
{path:"PA/Email/:url",component:EmailComponent},
{path:"PA/Login",component:LoginComponent},
{path:"PA/Login?returnUrl=:returnUrl",component:LoginComponent},
];
但它返回null。我在哪里犯错误
感谢您的帮助您正在尝试从
paramMap
获取查询参数,您应该在以下时间完成:
此外,路由器配置中不需要以下行:
{path:“PA/Login?returnUrl=:returnUrl”,component:LoginComponent},
您正试图从paramMap
获取查询参数,这时您应该通过:
此外,路由器配置中不需要以下行:
{path:“PA/Login?returnUrl=:returnUrl”,component:LoginComponent},
你能发布你的路由器配置吗?我有疑问你能发布你的路由器配置吗?我有疑问
this.route.snapshot.queryParamMap.get('returnUrl');