close

今天我想把object變成url

Object

let inputs = {

    name: kai,

    ID: 12,

}

Str

name=kai&ID=12

 

let str = Object.keys(inputs).map(function(e){

    return encodeURLComponent(e) + "=" + encodeURIComponent(inputs[e]);

}).join("&");

 

The encodeURI() function is used to encode a URI.

This function encodes special characters, except: , / ? : @ & = + $ # (Use encodeURIComponent() to encode these characters).

 

 

arrow
arrow
    文章標籤
    object url rup
    全站熱搜

    Kaikai凱開 發表在 痞客邦 留言(0) 人氣()