未捕获的DOMException:无法在“Window”上执行“postMessage”:无法克隆对象 [英] Uncaught DOMException: Failed to execute 'postMessage' on 'Window': An object could not be cloned

查看:292
本文介绍了未捕获的DOMException:无法在“Window”上执行“postMessage”:无法克隆对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正打算打电话

parent.postMessage(obj, 'whatever');

我收到此错误:未捕获的DOMException:无法在'Window'上执行'postMessage':无法克隆对象。

推荐答案

事实证明我传递的对象有方法,这就是为什么错误消息说无法克隆对象

It turns out the object I passed had methods, which is why the error message said An object could not be cloned.

为了解决这个问题,您可以执行以下操作:

In order to fix this, you can do the following:

obj = JSON.parse(JSON.stringify(obj));
parent.postMessage(obj, 'whatever');

这篇关于未捕获的DOMException:无法在“Window”上执行“postMessage”:无法克隆对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆