编码与解码

decodeURIComponent() 函数对 URI 组件进行解码。

encodeURIComponent() 函数对 URI 组件进行编码。

Example

var uri = "https://localhost:3000/index?name=张三&car=saab";
var uri_enc = encodeURIComponent(uri);       //'https%3A%2F%2Flocalhost%3A3000%2Findex%3Fname%3D%E5%BC%A0%E4%B8%89%26car%3Dsaab'
var uri_dec = decodeURIComponent(uri_enc);   //'https://localhost:3000/index?name=张三&car=saab'

 

 posted on 2022-04-20 14:18  boye169  阅读(362)  评论(0编辑  收藏  举报