<script>
var url=window.location.href
var url="http://www.baidu.com/20210720/page1.html?username=karen&pwd=123&cb=fn&count=20"
function querystringformart (url) {
var obj={}
var arr1=url.split("?")
//console.log(re)
if(arr1[1]){
var arr2=arr1[1].split("&")//["username=karen","pwd=123","cb=fn","count=20"]
arr2.map((el)=>{
var arr3=el.split("=")//["username","karen"]
obj[arr3[0]]=arr3[1]
})
}
return obj
}
var queryobj=querystringformart(url)
console.log(queryobj)