Expo react本机物理设备在本地主机上运行

时间:2021-05-05 02:57:27

标签: expo react-native-android

我只是expo init一个项目并启动它,然后使用我的物理设备在开发工具上扫描二维码局域网连接Expo Go< /strong> 但它不起作用。我意识到 expo go app 运行 127.0.0.1 而不是 pc ip。我该如何解决?


  Waiting on exp://127.0.0.1:19000 
  // It must be like this  Waiting on exp://192.168.1.10:19000

› Scan the QR code above with Expo Go (Android) or the Camera app (iOS)

› Press a │ open Android
› Press w │ open web

› Press r │ reload app
› Press m │ toggle menu in Expo Go
› Press d │ show developer tools
› shift+d │ toggle auto opening developer tools on startup (disabled)

› Press ? │ show all commands

Logs for your project will appear below. Press Ctrl+C to exit.```

2 个答案:

答案 0 :(得分:0)

expo start 之后,您应该会看到这样的输出

› Waiting on exp://192.168.100.74:19000
 › Scan the QR code above with Expo Go (Android) or the Camera app (iOS)

 › Press a │ open Android
 › Press w │ open web

 › Press r │ reload app
 › Press m │ toggle menu in Expo Go
 › Press d │ show developer tools
 › shift+d │ toggle auto opening developer tools on startup (disabled)

 › Press ? │ show all commands

Logs for your project will appear below. Press Ctrl+C to exit.

正如您在第一行看到的那样,它说 Waiting on exp://192.168.100.74:19000

现在确保您的 PC 和您的手机连接到同一网络。

然后在您的 Expo Go 应用程序中扫描二维码并完成..

此外,如果您同时登录了 Expo GO 应用程序和正在开发的笔记本电脑/PC,那么您应该会在 Recently in Development 部分看到您的项目。

我建议您同时登录两台设备..

PC:

在项目文件夹的终端中输入 expo login

输入凭据并登录。

移动设备:

在“个人资料”选项卡中登录您的世博会帐户。

答案 1 :(得分:0)

我通过使用二维码生成器并输入 exp://[MY_LAN_IP]:19000 而不是 exp://127.0.0.1:19000 来解决我的问题,然后对其进行扫描。 我不认为我的解决方案是正统的方法,但比使用模拟器更好