const searchKey = window.location.href.indexOf("?")
const searchUrl = searchKey > 0 ? window.location.href.slice(searchKey + 1) : ""
function queryParam(str) {
const result = {}
if (str.length > 0) {
str.split("&").forEach(element => {
const temp = element.split("=")
result[temp[0]] = temp[1]
})
}
return result
}
console.log(queryParam(searchUrl))
&
切割成数组。=
切割即可。