webview与RN通信,在html里发送通知:
window.postMessage(JSON.stringify({action: 0, data: data}));
发现RN的webview的onMessage监听不到,解决方案是为webview重写window.postMessage方法:
{this.webview = w}} onLoad={this.webviewload.bind(this)} source={{html: html}} onMessage={this.messageHandler.bind(this)} //重写webview的postMessage方法,解决RN无法监听html自带的window.postMessage injectedJavascript={`(function() { window.postMessage = function(data) { window.ReactNativeWebView.postMessage(data) } })();` }



