1. 下载组件 npm install react-native-webview-bridge --savejava
2. 自动连接库 react-native link react-native-webview-bridge react
3. 由于组件比较老,须要作改变引用头文件的方式,将组件全部的引用头文件都参考如下修改:(参考连接http://reactnative.cn/post/3277)web
例:#import <React/RCTView.h>
#import <UIKit/UIKit.h>
#import <React/RCTAutoInsetsProtocol.h>
#import <React/RCTConvert.h>
#import <React/RCTEventDispatcher.h>
#import <React/RCTLog.h>
#import <React/RCTUtils.h>
#import <React/RCTView.h>
#import <React/UIView+React.h>
#import <objc/runtime.h>
4. 在h5页面中引用webviewbridge.js,在点击事件中调用:npm
WebViewBridge.send(url)
5. 在React Native中接收:react-native
import WebViewBridge from 'react-native-webview-bridge'; .... onBridgeMessage(message) { const { webviewbridge } = this.refs; console.log('receiving message.....',message); this.props.nav.push({ component: Ad, title: '优惠商户', passProps:{ data:message, } }); } .... render(){ ... <WebViewBridge ref="webviewbridge" onBridgeMessage={this.onBridgeMessage.bind(this)} javaScriptEnabled={true} source={{uri: this.state.url, method: 'GET'}} style={{width: width, height:320,}} bonces={true} startInLoadingState={false} scalesPageToFit={true}/> .... }