1.主页面里写入,可以在url里面拼接参数和token

window.parent.postMessage({

 type:"iframe", 
 id:"other_"+parseInt(Math.random()*100),
 title:"电路详情列表",
 // url:"https://www.baidu.com/s?ie=UTF-8&wd=baidu"
 url:CORE_CONFIG.DETAIL_URL+'?objectid=' + val.OBJECTID + '&x_token=' + getToken()
                         },"*");

2.定义一个js方法,用来接收传递得参数 getUrl()

export function getUrl(name = "x_token",complex = false) {
  var reg = new RegExp("[^\?&]?" + encodeURI(name) + "=[^&]+");
  var arr = window.location.href.match(reg);
  if (arr != null) {
    return  complex ?
  decodeURIComponent(arr[0].substring(arr[0].search("=") + 1)) :		
  decodeURI(arr[0].substring(arr[0].search("=") + 1));
  }


  return "";
}

3.准备要跳转的页面接收 直接用getUrl获取参数

getUrl("objectid")

Logo

前往低代码交流专区

更多推荐