zhuanghaixin / Interview

8 stars 0 forks source link

[js]encodeURI和decodeURI 你知道吗? #213

Open zhuanghaixin opened 3 years ago

zhuanghaixin commented 3 years ago
let url = "http://localhost:8080/index.html?time=2018-01-09&title=63元黑糖颗粒固饮"

encodeURI()编码:
let encodeURI_url = encodeURI(url) = "http://localhost:8080/index.html?time=2018-01-09&title=63%E5%85%83%E9%BB%91%E7%B3%96%E9%A2%97%E7%B2%92%E5%9B%BA%E9%A5%AE"

decodeURI()解码:

decodeURI(encodeURI_url )= “http://localhost:8080/index.html?time=2018-01-09&title=63元黑糖颗粒固饮”
zhuanghaixin commented 3 years ago

JS对url进行编码和解码(三种方式)