angular - 从返回的 URL 中获取参数
问题描述
我想使用这个打字稿解析 GET 请求的结果:
return this.httpClient
.get('http://localhost:8080', options)
.pipe(
map((response: Response) => {
console.log(response)
})
);
我想code
从重定向的 http 响应中获取值:http://localhost:9000/callback?code=7CLwgh
。我怎样才能获得价值?
解决方案
您可以使用拆分字符串
var str="http://localhost:9000/callback?code=7CLwgh";
var sp=str.split("code=");
console.log(sp[1]);
推荐阅读
- java - 如何在 Android 中使用带有 if-else 语句的布尔值显示我的 TextView?
- dialogflow-es - Dialogflow:不要指望用户在没有结束对话的情况下做出回应
- c# - Dism 在 C# 的 CMD Shell 中无法识别
- scala - Seq[A]的scala自定义遍历
- javascript - 如何从 json/string 中删除特殊字符和特定单词?
- css - 强制现有网站打印移动版
- css - 使用纯 CSS 将 CSS var() 分配给另一个 CSS 元素的样式属性值?
- assembly - 了解 `lw` 和 `sw` 在 MIPS 程序中的实际工作方式
- react-native - “未定义不是函数”错误。为什么不工作?
- ui-automation - 如何在远程机器上使用 FlaUI 运行 UI 测试而不是 RDP 进入它?