简单方便
function getVariable(url, key) {
url = new URL(url);
return url.searchParams.get(key)
}
const url2 = new URL("https://example.com/login?user=someguy&page=news");
console.log(getVariable(url2, 'user'))
简单方便
function getVariable(url, key) {
url = new URL(url);
return url.searchParams.get(key)
}
const url2 = new URL("https://example.com/login?user=someguy&page=news");
console.log(getVariable(url2, 'user'))