Angular 路由器:从 navigatebyurl 返回的承诺被忽略
Angular router: promise returned from navigatebyurl is ignored
使用此代码:
this.router.navigateByUrl('/login');
我收到以下警告:忽略从 navigatebyurl 返回的承诺。我想如何以及何时处理这里的承诺?
P.S。我在 AuthGuard 的 canActivate
.
中使用它
navigateByUrl 函数 returns 一个承诺,因此您可以使用 .then() 方法:
this.router.navigateByUrl('/login').then(() => {
// Do something
});
使用此代码:
this.router.navigateByUrl('/login');
我收到以下警告:忽略从 navigatebyurl 返回的承诺。我想如何以及何时处理这里的承诺?
P.S。我在 AuthGuard 的 canActivate
.
navigateByUrl 函数 returns 一个承诺,因此您可以使用 .then() 方法:
this.router.navigateByUrl('/login').then(() => {
// Do something
});