let Urls = 'http://xxx/m/api/user?msg=1';
let Url = 'http://xxx/m/api/user'
let msg = {
a:"11",
b:"22",
c:"33"
}
function urlSplicing(url,obj){
if(url.indexOf('?')==-1){
url+='?'
}
Object.keys(obj).map((key)=>{
url += key + '=' + obj[key] +'&';
})
url = url.slice(0,url.length-1)
return url
}
console.log(urlSplicing(Urls,msg) )
console.log(urlSplicing(Url,msg))
把对象拼接到url上
于 2022-01-27 11:07:23 首次发布