获取url地址中问号后参数

  1. A系统 传参到 B系统

// _self 当前窗口,blank 新开窗口   
 const url = "http://localhost:8889/#/patientManage/basicInfo?id="+'6666668888888';
 window.open(url, 'blank');

  1. 方法一:B系统 接收参数

route.query.id

方法二:B系统 接收参数(主要用于确定有参数携带)

    const getAllParams = () => {
      // 获取地址中的地址
      let href = window.location.href;
      // 截取问号后面的query参数
      let query = href.substring(href.indexOf("?") + 1);
      // 以&符号分割
      let item = query.split("&");
      let obj = {};
      for (let i = 0; i < item.length; i++) {
        let arr = item[i].split("=");
        // 参数名,参数值 赋值 对象的属性名,属性值
        obj[arr[0]] = arr[1];
      }
      return obj;
    };
    let querys = getAllParams();

猜你喜欢

转载自blog.csdn.net/yf18040578780/article/details/129655511