const getQueryByName = (name) => {
const queryNameRegex = new RegExp([?&]${name}=([^&]*)(&|$))
const queryNameMatch = window.location.search.match(queryNameRegex);// 路由前边
const queryParamsMatch = window.location.hash.match(queryNameRegex); // 路由后边
return queryNameMatch ? decodeURIComponent(queryNameMatch[1]) : queryParamsMatch ? decodeURIComponent(queryParamsMatch[1]) : ''
}
const name = getQueryByName('XXX') console.log(name)