我想通过导航为path来访问API this.router.navigate([“ salesfunnel”,5,userId,this.startDate,status,this.endDate,isSource]);;
那时,我的用户ID是“数字市场”。两者之间有一个空格。
但要正确导航到所需的路径,我想将其编码为 “数字%市场”。
到目前为止,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为:
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
最后,我希望数字市场成为Digital%Market,而不是Digital%20Market
答案 0 :(得分:0)
在我的情况下,我找到了答案,我刚刚使用了打字稿的替换方法,例如
userId.replace(“”,“%”)。
它将用%符号替换空格。
就这样!