function objectToQuery(object) {
return Object.keys(object)
.map(function (key) {
return key + '=' + encodeURIComponent(object[key])
})
.join('&')
}
eg: objectToQuery({
a:'1',
b:'fjfj',
c:'哈哈'
});
//a=1&b=fjfj&c=%E5%93%88%E5%93%88复制代码
转载于:https://juejin.im/post/5bdd3b8b51882516f1541864