<WebView style={{width: width, height: height, marginBottom: 20}} source={{ uri: this.props.route.params.url }} injectedJavaScript={this.props.route.params.injectedJavaScript} javaScriptEnabled={true} domStorageEnabled={true} mixedContentMode={'compatibility'} onMessage={(event) => { console.log('event: ', event) }} />
解决办法:WebView配置上onMessage属性,injectedJavaScript注入的JS代码就生效了