- react native 中添加webview
- react-native-webview postMessage
- React Native react-native-webvie
- 关于 React Native 与 WebView 的通信
- react-native-webview20-04-27
- react-native-webview HTML和RN通信 互
- ReactNative WebView 与H5页面的交互
- react-native-webview的console.log
- react-native-webview IOS低版本中h5长按
- react-native-webview支持type="file
1.在render中添加
<View>
<WebView
style={{height:300,width:300}}
ref={'webView'}
source={{uri: MAP_DATA_URL}} //此处URL为服务器返回的html
javaScriptEnabled={true}
onLoadEnd={this.pageOnLoaded.bind(this)}
/>
</View>
2.在类中添加pageOnLoaded方法:
pageOnLoaded() {
let data = {
key:'app',
url: 自己定义的url,//此处的url为请求服务器时的URL
parameter:12,
};//参数按照自己的需求去定义
this.refs.webView.postMessage(JSON.stringify(data));//必须转化成字符型
}
网友评论