JS url解码
1JS url解码
在JavaScript中对URL解码可以使用decodeURIComponent()函数。该函数将被编码过的URI组件进行解码。

例如,我们要解码以下URL:

https%3A%2F%2Fwww.google.com%2Fsearch%3Fq%3Djavascript%26rlz%3D1C1GCEA_enUS832US832%26oq%3Djavascript%26aqs%3Dchrome..69i57j69i60l2j0l3.3729j1j9%26sourceid%3Dchrome%26ie%3DUTF-8

可以使用如下代码进行解码:

const url = "https%3A%2F%2Fwww.google.com%2Fsearch%3Fq%3Djavascript%26rlz%3D1C1GCEA_enUS832US832%26oq%3Djavascript%26aqs%3Dchrome..69i57j69i60l2j0l3.3729j1j9%26sourceid%3Dchrome%26ie%3DUTF-8";
const decodedUrl = decodeURIComponent(url);
console.log(decodedUrl);

输出结果如下:

https://www.google.com/search?q=javascript&rlz=1C1GCEA_enUS832US832&oq=javascript&aqs=chrome..69i57j69i60l2j0l3.3729j1j9&sourceid=chrome&ie=UTF-8
本页由《梦行文档》生成

 

name完成
30