Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/224.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 使用react native webview转到localhost:9000/登录时,获取net::ERR\u连接被拒绝_Android_Webview_React Native - Fatal编程技术网

Android 使用react native webview转到localhost:9000/登录时,获取net::ERR\u连接被拒绝

Android 使用react native webview转到localhost:9000/登录时,获取net::ERR\u连接被拒绝,android,webview,react-native,Android,Webview,React Native,对不起,如果这是一个愚蠢的问题,但我是新来的,并试图理解 我的节点服务器运行在localhost:9000上,我正在尝试让webview正常工作。这就是我想要回报的- <View style={[styles.container]}> <WebView ref={'webview'} automaticallyAdjustContentInsets={false} style={styles

对不起,如果这是一个愚蠢的问题,但我是新来的,并试图理解

我的节点服务器运行在localhost:9000上,我正在尝试让webview正常工作。这就是我想要回报的-

      <View style={[styles.container]}>
        <WebView
          ref={'webview'}
          automaticallyAdjustContentInsets={false}
          style={styles.webView}
          source={{uri: 'http://localhost:9000/login'}}
          javaScriptEnabled={true}
          onNavigationStateChange={this.onNavigationStateChange.bind(this)}
          startInLoadingState={true}
          scalesPageToFit={true}
        />
      </View>

但是,这不起作用,因为我得到以下错误:

加载页面对象时遇到错误{canGoForward:false,code:-6,canGoBack:false,说明:“net::ERR\u连接被拒绝”,加载:false…}canGoBack:false canGoForward:false代码:-6说明:“net::ERR\u连接被拒绝”加载:false目标:9标题:“url:”http://localhost:9000/login"__proto\uuuuuuuuuuuuuuuuuuuuuuuuoObjectReactConsoleError@ExceptionsManager.js:76console.error@YellowBox.js:48onLoadingError@WebView.android.js:300proxiedMethod@createPrototypeProxy.js:44invokeGuardedCallback@ReactErrorUtils.js:26 Executedispatch@EventPluginUtils.js:87 ExecutedispatchesNorder@EventPluginUtils.js:110 ExecutedispatcheEventPluginHub.js:42已执行的DispatchesAndreleaseToplevel@EventPluginHub.js:53 ForeachAccumred@ForeachAccumred.js:26processEventQueue@EventPluginHub.js:215runEventQueueInBatch@ReactEventEmitterMixin.js:18 HandletoLevel@ReactEventEmitterMixin.js:29(匿名函数)@ReactNativeEventMitter.js:122perform@Transaction.js:136BatchedUpdate@ReactDefaultBatchingStrategy.js:63BatchedUpdate@ReactUpdates.js:97_ReceiveRootNodeEvent@ReactNativeEventMitter.js:121receiveEvent@ReactNativeEventMitter.js:135_uCallFunction@MessageQueue.js:185(匿名函数)@MessageQueue.js:89guard@MessageQueue.js:43callFunctionReturnFlushedQueue@MessageQueue.js:88onmessage@debuggerWorker.js:39


当我将源uri设置为或其他内容时,webview工作正常。有人能帮忙吗?谢谢

本地主机将是Android设备本身。要从Android emulator中访问您的主机操作系统,您可以使用
10.0.2.2:9000
或您的实际IP地址。

就我个人而言,我更愿意使用
adb反向tcp:9000 tcp:9000

谢谢Daniel。实际上,我必须把我的计算机的本地IP:端口放进去才能使用它完美的解决方案。这是一个无聊的时刻。请尝试使用mac终端中的(ifconfig | grep inet)或windows cmd中的(ipconfig/ALL)查找计算机的IP地址。其中一个应该用作WebView uri:exhttp://194.178.1.2:4242/my-局部端点