All files / src/utils getRequestParam.js

0% Statements 0/10
0% Branches 0/4
0% Functions 0/1
0% Lines 0/7

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17                                 
/**
 * @author SoldierAb
 * @description  获取地址栏参数
 * @param {String} str 字符串
 */
 
export default (str) => {
  let urlParamStr = str || window.location.href.split('?')[1]; //获取url中"?"符后的字串
  if(!urlParamStr) return 'urlParamStr param is null';
  let theRequest = {},strs = urlParamStr.split("&");
  for (let i = 0; i < strs.length; i++) {
    let splitObj=strs[i].split("=");
    theRequest[splitObj[0]] = decodeURI(splitObj[1]);
  }
  return theRequest;
}