gpt4 book ai didi

angular - 读取 Angular 4 防护中的查询字符串参数?

转载 作者:行者123 更新时间:2023-12-01 23:54:28 24 4
gpt4 key购买 nike

我正在尝试读取 Angular 防护的 canActivate 方法内的查询字符串参数。不幸的是,即使查询字符串存在,ActivatedRouteSnapshotRouterStateSnapshot 中的 queryParams 参数都是空的。

示例:bla.com/?uid=123

该查询字符串参数可以发送到任何 URL,我希望我的 guard 能够查看它。

最佳答案

示例网址: http://example.com/oper/sale?code=you_code_here

import { ActivatedRouteSnapshot } from "@angular/router";
...

canActivate(route: ActivatedRouteSnapshot) {
console.log("code", route.queryParams.code);
}

关于angular - 读取 Angular 4 防护中的查询字符串参数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43054562/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com