方式一:字符串截取成数组的方式
let url = window.location.href
url = url.substring(url.indexOf('?') + 1)
arr = url.split('&')
for (let i = 0; i < arr.length; i++) {
this.lastParams[arr[i].substring(0, arr[i].indexOf('='))] = arr[i].substring(arr[i].indexOf('=') + 1)
}
方法二:正则表达式的方式
let url = 'https://www.baidu.com/s?sysId=111111&wd=substr&abb=222222'
let localUrl = url.substr(url.indexOf('?'))
console.log(localUrl)
debugger
var sysId = getQuertString('abb',localUrl)
console.log(sysId)
function getQuertString (name, url) {
let reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i')
let result = url.substr(1).match(reg)
if (result !== null) {
return unescape(result[2])
}
return null
}