localhost变更为ip地址原因

移动端的开发页面想要在手机端查看,使用localhost是无法查看的只有使用IP地址才可以通过本机IP访问该页面,查看页面效果

变更方法

查看本机 IP 地址

调出cmd命令行,输入cmd按enter键
WEBSTORM-localhost变更为ip地址查看
输入ipconfig
WEBSTORM-localhost变更为ip地址查看
获取本机ip地址:192.168.0.41

设置 webstorm 选项

弹出设置选项卡
WEBSTORM-localhost变更为ip地址查看

设置端口号,选择debuggerWEBSTORM-localhost变更为ip地址查看

需要选择上图红框中内容,否则手机端无法访问

设置localhost变更

点击 + ,输入 localhost
WEBSTORM-localhost变更为ip地址查看
设置connection

  1. 设置项目的根目录
  2. 设置项目的WebServerUrl:本地ip地址+设置的端口号

设置mappings
1.Local path 有个默认值,也即是项目的根目录,不做修改
2.开发路径设置为“\”即可
3.Web path设置为"/"即可
WEBSTORM-localhost变更为ip地址查看
点击Apply,Ok 按钮
打开要查看的html页面,点击浏览器查看
WEBSTORM-localhost变更为ip地址查看
发现路径缺少projectName
因此调整connection、mapping设置
Local path ,也即是项目的根目录,设置为该目录的上级目录
WEBSTORM-localhost变更为ip地址查看
WEBSTORM-localhost变更为ip地址查看

打开要查看的html页面,点击浏览器查看,此时路径正确

相关文章:

  • 2022-12-23
  • 2021-12-12
  • 2022-01-01
  • 2021-12-22
  • 2021-04-11
  • 2021-08-16
  • 2021-04-12
  • 2022-01-02
猜你喜欢
  • 2021-12-05
  • 2022-12-23
  • 2022-01-01
  • 2021-09-24
  • 2022-01-27
  • 2021-12-21
  • 2021-12-29
相关资源
相似解决方案