简体   繁体   English

Webview不显示任何内容(html)反应本机

[英]Webview not showing any content(html) react native

Contents did showing up perfectly inside emulator and debug with real device but does not showing anything when testing out with real device (using released .apk) . 内容确实在模拟器中完美显示,并使用真实设备进行调试,但使用真实设备进行测试(使用已发布的.apk)时却未显示任何内容。 It just only showed blank container with white color. 它只显示了白色的空白容器。 Or do i missed something? 还是我错过了什么?

<WebView
     ref={(wView) => {this.wView = wView}}
     javaScriptEnabled={true}
     // onBridgeMessage={this.onBridgeMessage}
     onMessage={this.onMessage}
     injectedJavaScript="window.postMessage = String(Object.hasOwnProperty).replace('hasOwnProperty', 'postMessage');"               
     automaticallyAdjustContentInsets={false}
     domStorageEnabled={true}
     startInLoadingState={true}
     source={mainHtml} <-- load with, var mainHtml = require('./MainHtml.html');
     style={{width: 320,height:100,flex: 1}}/>

Environment 环境

  • react-native-cli: 2.0.1 react-native-cli:2.0.1

  • react-native: 0.43.4 反应本机:0.43.4

  • react: 16.0.0-alpha.6 反应:16.0.0-alpha.6

  • Device(ASUS Zenfone) 设备(华硕Zenfone)

  • Android version 6.0.1 Android版本6.0.1

From what I've read here this is a known issue with Android when deploying in Release. 根据我在此处阅读的内容在Release中进行部署时这是Android的已知问题。 The workaround is to point to the file with a uri : 解决方法是使用uri指向文件:

{ uri: 'file:///pathto/file.html' }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM