获取当前路径里面的参数
2021-05-26 本文已影响0人
fanyu__
/** 获取指定参数名的值 */
static getUrlPara(name: string) {
const url = window.location.href
const arr = url.split('?')
if (arr.length === 2) {
const paras = arr[1]
const arr2 = paras.split('&')
if (arr2.length > 0) {
for (let i = 0; i < arr2.length; i++) {
const item = arr2[i]
const arr3 = item.split('=')
if (arr3.length === 2 && arr3[0] === name) {
return arr3[1]
}
}
}
}
}