父业面iframe:

<div id="vue">
	<iframe id="mainiframe" width="100%" height="100%" frameborder="no" border="0" marginwidth="0" marginheight="0" scrolling="auto" src="../swap/finance/index.html?CID=13123jklkljlajkj"></iframe>
</div>

子页面获取src里的参数:

var headers = {}
headers.Token = GetIframeQueryString('CID', 'mainiframe')
function GetIframeQueryString (name, id) {
  var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i')
  var r = window.parent.document.getElementById(id).contentWindow.location.search.substr(1).match(reg)
  if (r != null) {
    return decodeURI(r[2])
  }
  return null
}

 

Logo

前往低代码交流专区

更多推荐