url,得到其中相关的参数
export function getCode(){
var search = window.location.hash
getURLParameter(search, 'code')
}
// 获取url中对应的参数
function getURLParameter(url, paramName) {
var urlParams = url.split("?")[1]//或者url.search获取参数字符串
var paramArray = urlParams.split("&")
var len = paramArray.length
var paramObj = {}//json对象
var arr = []//数组对象
for (var i = 0; i < len; i++) {
arr = paramArray[i].split("=")
paramObj[arr[0]] = arr[1]
}
for (key in paramObj) {
if (key == paramName) {
return paramObj[paramName]
break
}
}
}
网友评论