原因
当时的iframe是动态生成的,未加载好就发送postMessage,webpack帮助了发送,所以出现webpackOk
解决方案
const targetIframe = document.getElementById('targetIframe')
const info = { sign: '标识' }
targetIframe.onload = () => {
targetIframe.contentWindow.postMessage(info,'*')
}
当时的iframe是动态生成的,未加载好就发送postMessage,webpack帮助了发送,所以出现webpackOk
const targetIframe = document.getElementById('targetIframe')
const info = { sign: '标识' }
targetIframe.onload = () => {
targetIframe.contentWindow.postMessage(info,'*')
}
github:https://github.com/zhuishao/
查看归档 →
“postMessage没接收到值只接收到webpackOk”上的1条回复
Hello