重写window.postMessage
<WebView
ref={ref=>{
this.webView = ref
}}
style={{flex:1}}
source={{uri:getApi('/h5/invitation/mine')}}
onMessage={(event)=>{
const data = event.nativeEvent.data
this.handleMessage(JSON.parse( data) )
}}
onLoad={()=>{
}}
javaScriptEnabled={true}
injectedJavaScript={`(function() {
window.postMessage = function(data) {
window.ReactNativeWebView.postMessage(data)
}
})();`
}
/>
网友评论