另一台计算机上的实时服务器vscode

问题描述

我有2台计算机。当我在第一个服务器上打开带有实时服务器的项目时,它会给我这个URL 127.0.0.1:5500/index.html 我想将该URL放在另一台计算机的浏览器上,但是它不起作用。 有什么解决办法吗?

解决方法

您可以尝试在主机计算机上使用Powershell进行端口转发。我使用wsl2,当我想在另一台计算机上预览时,我使用powershell进行转发

[`para 1.`,<br />,`para 2`]

description: [
  <span className="yourClass">{one}</span>," advanced diverted domestic sex repeated bringing you old.
  Possible procured her trifling laughter"
]

在您的情况下,请尝试使 listenaddress connectaddress (这是您的主计算机)相同,并使用以下命令监听和连接端口5500上面的脚本。

在那之后,您应该执行的最后一步是在防火墙内添加入站规则。

,

您可以转到设置实时服务器并检查使用本地IP选项,然后停止实时服务器并重新开始。 现在实时服务器使用本地 ip 的方向,您可以在其他电脑上打开您的文件。 enter image description here

,

这就是在 VS Code 中对我有用的方法:

1.- 转到您的扩展选项:

enter image description here

2.- 确保您选中了“使用本地 IP”选项: enter image description here

3.- 在您的终端上检查您的本地 IP 地址(例如 Windows 上的 ipconfig)并将您的实时服务器 url 中的 ip 地址替换为您的本地 ip:

enter image description here

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...