获取location中search的值
location.href = 'http:www.baidu.com?name=zhang3&age=18'
URL
const searchParams = new URL(location.href).searchParams
const name = searchParams.get('name')
const age = searchParams.get('age')
console.log(name) // zhang3
console.log(age) // 18
URLSearchParams
const searchParams = new URLSearchParams(location.search);
const name = searchParams.get('name')
const age = searchParams.get('age')
console.log(name) // zhang3
console.log(age) // 18