javascript 編碼 解碼 欄目 JavaScript 简体版
原文   原文鏈接

編碼

encodeURI(str);

eg:let b=encodeURI("a=漢子");
    console.log(b);
    結果爲:"a=%E6%B1%89%E5%AD%90"
複製代碼

特色:對一些符號沒法進行編碼:如:':','/',';','='等等

encodeURIComponent(str) ;

eg:let b=encodeURIComponent("a=漢子");
    console.log(b);
    結果爲:"a%3D%E6%B1%89%E5%AD%90"
複製代碼

特色:能夠對特殊符號進行編碼

解碼

decodeURI(str);

eg:let b=decodeURI(b=%E6%B1%89%E5%AD%90);
    console.log(b)
    結果爲:a="漢子"
複製代碼

decodeURIComponent(str);

eg:let b=decodeURIComponent("a%3D%E6%B1%89%E5%AD%90");
    console.log(b);
    結果爲:a="漢子";複製代碼
相關文章
相關標籤/搜索
每日一句
    每一个你不满意的现在,都有一个你没有努力的曾经。
本站公眾號
   歡迎關注本站公眾號,獲取更多信息