获取url?后参数等值

getUrlParameter (param, dummyPath) {
let sPageURL =
window.location.hash || window.location.search.substring(1)
// console.log(sPageURL)
let sURLVariables = sPageURL.split(/[&||?]/)
// console.log(sURLVariables)
let res = ''
for (let i = 0; i < sURLVariables.length; i += 1) {
let paramName = sURLVariables[i]
let sParameterName = (paramName || '').split('=')
// console.log(sParameterName)
if (sParameterName[0] === param) {
res = sParameterName[1]
}
}
return res
},

你可能感兴趣的:(获取url?后参数等值)