我想通过导航到this.router.navigate(“this.router.navigate”,5,userId,this.startDate,status,this.endDate,isSource)路径来访问API;
在这一点上,我的userId是“数字市场”。在两者之间有一个空间。
但为了正确导航到所需的路径,我想将其编码为"Digital%Market“。
到目前为止,URI是:http://103.21.187.5:8090/tripleplay/lead/filter?type=Digital Market&status=PAYMENT_PENDING_EKYC_LEAD,
数字与市场之间有空间
但是所需的URI是:http://103.21.187.5:8090/tripleplay/lead/filter?type=Digital%Market&status=PAYMENT_PENDING_EKYC_LEAD。
我试着像encodeURI(userId)那样做,然后将它作为参数传递给router.navigate()方法,购买它的显示URI为:
http://103.21.187.5:8090/tripleplay/lead/filtertype=Digital%20Market&status=PAYMENT_PENDING_EKYC_LEAD
Present URI:
URI is : http://103.21.187.5:8090/tripleplay/lead/filter?
type=Digital Market&status=PAYMENT_PENDING_EKYC_LEAD
Required URI:
URI is : http://103.21.187.5:8090/tripleplay/lead/filter?
type=Digital%Market&status=PAYMENT_PENDING_EKYC_LEAD最后,我希望数字市场是数字%市场,而不是数字%20Market
发布于 2019-08-02 18:09:17
在我的例子中,我找到了答案,我刚刚使用了typescript的替换方法,如下所示
userId.replace(“","%")。
它将用%符号替换空格。
就是这样!
https://stackoverflow.com/questions/57323576
复制相似问题