亲测可用,若有疑问请私信
"use strict";
var objectToQueryString = function objectToQueryString(obj) {
return Object.keys(obj).map(function (key) {
return "".concat(encodeURIComponent(key), "=").concat(encodeURIComponent(obj[key]));
}).join('&');
};
objectToQueryString({
name: 'Jhon',
age: 18,
address: 'beijing'
});
结果为
name=Jhon&age=18&address=beijing