我们在命令行启动本地angular2+项目时,可以默认使用了localhost,这是使用127.0.0.1代替也是可以正常访问的。
如果我们使用ip地址访问则不行

这时候需要启动的时候在命令行以ip启动

这时候在用ip就可以访问了,这时候如果在host文件里做本地域名解析。

这时候我们用解析的域名访问

这时候会报错,在命令行ping地址的话可以ping的通。
解决方法

加上--disable-host-check启动,解决。或者在webpack配置文件里添加: disableHostCheck : true.
网友评论