Get the parameters after the question mark in the url address

  1. Transfer parameters from system A to system B

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

  1. Method 1: System B receives parameters

route.query.id

Method 2: System B receives parameters (mainly used to determine whether there are parameters to carry)

    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();

Guess you like

Origin blog.csdn.net/yf18040578780/article/details/129655511