nie*_*eve 40 javascript iframe postmessage
我正试着打电话
parent.postMessage(obj, 'whatever');
Run Code Online (Sandbox Code Playgroud)
在iframe中,我收到此错误: Uncaught DOMException: Failed to execute 'postMessage' on 'Window': An object could not be cloned.
nie*_*eve 70
事实证明我传递的对象有方法,这就是错误消息所说的原因An object could not be cloned.
为了解决这个问题,您可以执行以下操作:
obj = JSON.parse(JSON.stringify(obj));
parent.postMessage(obj, 'whatever');
Run Code Online (Sandbox Code Playgroud)