一:跨iframe操作DOM
window.parent.document.getElementById('id').style.zIndex = '100';
如果两个iframe 域名不同,会报错
二:跨iframe传递参数
1、子级iframe给父级传递参数
// 子iframe,发送方:
window.postMessage("hello", "http://localhost:8081");
// 父iframe, 接收方:
window.addEventListener( "message",
(e)=>{console.log(e.data)}
false);
2、父级iframe向子iframe传值
直接在iframe的src数属性中拼接上参数
// 发送方:
<div>
<iframe :src="url" id="childFrame" importance="high" name="demo" ></iframe>
</div>
url = `http://localhost:8080/couponManager?a={a}` //
接收方:直接使用window.location.search接收,然后对接收到的进行处理