Loading

Loading

从URL获取参数

function getURLParam() {
  const url = location.search;
  const param: any = {};
  if (url.indexOf('?') != -1) {
      const str = url.substr(1);
      const strs = str.split('&');
      for(let i = 0; i < strs.length; i ++) {
        param[strs[i].split('=')[0]] = decodeURI(strs[i].split('=')[1]);
      }
  }
  return param;
}
posted @ 2020-12-31 15:19  灰色的修饰  阅读(118)  评论(0编辑  收藏  举报