为什么我不能在手机浏览器上输入网址来查看我的直播网站? [英] Why can't I enter the url on my phone's browser to view my live site?

查看:99
本文介绍了为什么我不能在手机浏览器上输入网址来查看我的直播网站?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Visual Studio Code 中使用了一个名为 Live Server 的扩展.当我实时运行时,浏览器打开,网址为 http://127.0.0.1:5500/index.html.为什么我在手机浏览器上打不开这个网址,在手机上看直播网站.有没有办法做到这一点(在手机和浏览器上实时重新加载)?

I use an extension called Live Server in Visual Studio Code. When I run live, the browser opens and the url is http://127.0.0.1:5500/index.html. Why can't I open this url on my phone's browser to see the live site on the phone. Is there a way to do this (Live reload on phone and browser)?

注意:我也使用 ionic 进行开发,当我 ionic serve 时,我可以在浏览器上看到它,当我打开 ionic dev 应用程序(不是 ionic 视图!)时,我可以在手机上看到实时应用程序.我可以在多个设备上查看它,条件是所有设备都在我可以使用的同一网络中.

Note: I also develop using ionic and when I ionic serve I can see it on browser and when I open the ionic dev app (not ionic view!), I can see the live app on the phone. I can view it on multiple devices with the condition of all devices being in the same network which I am fine with.

推荐答案

127.0.0.1 是为环回目的保留的专用 IPv4 地址.也就是说,这个IP是指你的电脑本身.

127.0.0.1 is a special-purpose IPv4 address reserved for loopback purposes. That is, this IP refers to your computer itself.

在浏览器中输入 http://127.0.0.1:5500/index.html,您正在计算机中请求网页.

By entering http://127.0.0.1:5500/index.html in your browser, you're requesting web page within your computer.

在正常情况下,您的计算机将位于 NAT 网络中(例如在同一个 Wi-Fi AP 下),并且您将被分配一个虚拟 IP.通常是 192.168.x.x.

In normal case, your computer will be in a NAT network (under same wi-fi AP for instance), and you'll be assigned with a virtual IP. Normally it's 192.168.x.x.

您可以在命令提示符中输入以下命令来查看您的 IP 地址.

You may enter the following command in your command prompt to see your IP address.

ipconfig

如果您使用的是 Mac 或 Linux,请改用它.

If you're using Mac or Linux, use this instead.

ifconfig

因此,在您的网络接口卡下,您将获得IP 地址.

As a result, under your network interface card, you'll get your IP Address.

如果IP地址属于虚拟IP,那么您可以使用手机访问它

If the IP address belongs to virtual IP, then you may access it with your phone using

http://< Your IP Address >:5500/index.html

如果不是虚拟IP,那就是公共IP.然后,您必须在这种情况下配置适当的防火墙设置.

If it's not virtual IP, it is Public IP. Then, you'll have to configure appropriate Firewall settings under this circumstance.

希望这会有所帮助.

这篇关于为什么我不能在手机浏览器上输入网址来查看我的直播网站?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆