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');
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…