今天我想把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).

 

 

文章標籤
全站熱搜
創作者介紹
創作者 Kaikai凱開 的頭像
Kaikai凱開

凱開 x 慵懶日子

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