我已经正确地实现了深层链接功能,但是在获取URL我的当前URL的%20之后我有一个问题:
在上述URL中,我们通过searchparams获得了categoryname的值:
//从URL获取键值 var name = currentURL.searchParams.get('categoryname');
它将仅返回“ Beauty”而不是“ Beauty&Wellness”。我将从上面的URL中获得整个类别名称值,但在我当前的情况下,它将仅返回Beauty。告诉我如何获取ionic2或javscript中%20之后的值?
答案 0 :(得分:1)
如果要创建URL,则需要percent-encode“ Beauty”和“ Wellness”之间的“&”号。例如Beauty%20%26%20Wellness:
const link = 'https://halarewards.com/geturl.php?URL_SCHEME=HalaRewards://app/alloffers&DEEPLINK_SCHEME=https&DEEPLINK_HOST=halarewards.com&pagename=alloffers&categoryname=Beauty%20%26%20Wellness'
const url = new URL(link);
alert(url.searchParams.get('categoryname')); // "Beauty & Wellness"