iframeの使用(マージ可能)

1: iframe 間で DOM を操作する

window.parent.document.getElementById('id').style.zIndex = '100';

2 つの iframe のドメイン名が異なる場合、エラーが報告されます。

2: 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接收,然后对接收到的进行处理

おすすめ

転載: blog.csdn.net/sun_qqq/article/details/130593704