首页 > 解决方案 > 如何以角度编码 URL?

问题描述

我试图将一个以国家代码“+91”开头的手机号码编码为 %2B ..使用代码

{ 
 this.uri = "+919658452565;
 this.res = encodeURIComponent(this.uri)
}

在编码结束时得到 %2B919658452565;

但是当我在 URL 参数中传递 this.uri

const params = new URLSearchParams();
params.append('personContactPhNo', this.uri);                                                                  this.baseURL= "https://sfghfhfhfghtgj.com/"; 
let options = new RequestOptions({ headers: headers, params: params }) 
this.httpClient.get(this.baseURL+'Dev', options)

我收到错误为 %252B919658452565... 帮助解决此问题

标签: javascriptangulartypescriptangular5angular7

解决方案


推荐阅读