本文共 745 字,大约阅读时间需要 2 分钟。
报错如下:
Setting onMessage on a WebView overrides existing values of window.postMessage, but a previous value was defined.解决方法:
(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; //业务代码 $("#header").hide(); $(".consultBtn").click(function(){ window.postMessage("gochat") }) })();
转载地址:http://elqpo.baihongyu.com/