angular路由守卫
import { CanActivateChild, Router, ActivatedRouteSnapshot } from '@angular/router';
export class AuthGuard implements CanActivateChild {
public async canActivateChild(childRoute: ActivatedRouteSnapshot) {
const toOpen = childRoute.routeConfig.path === 'child'
if (toOpen) {
this.buyAcc.getSub().subscribe((res) => {
if (res['status'] !== 0) {
this.modal.warning({content: res['data']});
return false;
}
});
} else {
return true;
}
}
}