如何使用手机打开localhost:4200?

编程入门 行业动态 更新时间:2024-10-17 15:32:40
本文介绍了如何使用手机打开localhost:4200?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我的手机和PC位于同一个wifi中.运行ng serve时,我可以在PC上使用Chrome在localhost:4200中打开它,

My phone and pc are in same wifi. When I run ng serve, I open localhost:4200 in Chrome with my PC, which works.

但是我用手机打开192.168.1.107:4200,但无法使用.

But I open 192.168.1.107:4200 with my mobile phone, and it doesn’t work.

当我使用create-react-app时.有用.

绿色是有角的.白起反应

Green is angular. White is react

推荐答案

为了使您的服务器在本地网络中可用,您需要使用以下命令:

In order to make your server available in local network, you need to use the following command:

ng serve --host 192.168.1.107

然后该应用将在网络中每台设备的192.168.1.107:4200上可用.

And then the app will be available on 192.168.1.107:4200 on every device in your network.

如果您不知道您的LAN地址是什么,则可以在基于unix的OS上执行ifconfig | grep broadcast-第一个IP是您的计算机,或者在Windows计算机上是ipconfig.

If you don't know what is your LAN address you can execute ifconfig | grep broadcast on unix-based OS - the first IP is your computer, or ipconfig on Windows machine.

更多推荐

如何使用手机打开localhost:4200?

本文发布于:2023-11-27 07:43:15,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1637157.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何使用   手机   localhost

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!