报错如下:
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")
})
})();