我当前正在使用LazyLoading
加载模块,但是重新加载页面时我无法访问路由器参数。
重新加载时,路由器参数为空,但是我可以在组件内访问,但不能访问Guard
。
代码
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): any {
debugger;
console.log(route.params); // empty when reloading
this.router.events.subscribe((event) => {
if (event instanceof ActivationStart) {
console.log(event);
}
});
}
上面的代码没有记录任何console events
,因为routing does not happen
重新加载页面后,如何在CanActivate
中访问路由参数?有没有黑客可以让我访问它们?