一般出现在WebView组件里监听onMessage时造成的
解决方法:
在该组件render方法里面粘贴如下代码
const patchPostMessageFunction = function() {
var originalPostMessage = window.postMessage;
var patchedPostMessage = function(message, targetOrigin, transfer) {
originalPostMessage(message, targetOrigin, transfer);
};
patchedPostMessage.toString = function() {
return String(Object.hasOwnProperty).replace('hasOwnProperty', 'postMessage');
};
window.postMessage = patchedPostMessage;
};
const patchPostMessageJsCode = '(' + String(patchPostMessageFunction) + ')();';
同时Webview组件里添加如下代码
injectedJavaScript={patchPostMessageJsCode}
如上图操作即可