分类
javascript

postMessage没接收到值只接收到webpackOk

原因

当时的iframe是动态生成的,未加载好就发送postMessage,webpack帮助了发送,所以出现webpackOk

解决方案

const targetIframe = document.getElementById('targetIframe')
const info = { sign: '标识' }
targetIframe.onload = () => {
    targetIframe.contentWindow.postMessage(info,'*')
}

由zhuishao

github:https://github.com/zhuishao/

“postMessage没接收到值只接收到webpackOk”上的1条回复

发表评论

电子邮件地址不会被公开。 必填项已用*标注