脚手架3或4在创建安装依赖并运行后会有以下打印:
![](https://img-blog.csdnimg.cn/img_convert/219647147aebe403fc7c19e183567710.png)
可以看到所需环境已配置完毕,所以只有脚手架2需要自己配置。
脚手架2在创建安装依赖并运行后会有以下打印:
![](https://img-blog.csdnimg.cn/img_convert/a19e1ba12dce7c03ae771888f02049a6.png)
第一步需要打开根目录下build文件夹中webpackdev.conf.js
![](https://img-blog.csdnimg.cn/img_convert/e3b248546507de70e5378dfffb5cd87f.png)
并寻找到这一句:
![](https://img-blog.csdnimg.cn/img_convert/16932fa9f11318f71d1e957d3ebac4bb.png)
只需要将其改为:
messages: [
`Your application is running here: http://localhost:${port}`,
`Network: http://${require('ip').address()}:${port}`,
],
第二步需要打开根目录下config文件夹中的index.js文件
![](https://img-blog.csdnimg.cn/img_convert/71f0ce2e34ac1ce182aed150ff8f5b6e.png)
并找到这一句:
![](https://img-blog.csdnimg.cn/img_convert/89e6737ae6d4bc53a29c6f249d44f9f2.png)
将localhost改为0.0.0.0,如下
![](https://img-blog.csdnimg.cn/img_convert/9e7857aa2501d4493b0ea8d4002c66f0.png)
再启动项目就会有如下打印:
![](https://img-blog.csdnimg.cn/img_convert/6871bf75498accc25ebaf217ea5cc259.png)
我这里出现的169.254是链路本地地址,并不是IPv4地址,同一网络或wifi下的系统还是不能打开,一般情况启动后打印的都是IPv4,还没有找到为什么会打印这个地址。只需要看一下自己的当前网络下的IPv4地址就好了
![](https://img-blog.csdnimg.cn/img_convert/b60cb897dc542be52d0fb177985fcc3b.png)
然后再浏览器输入地址加端口号,同一网络环境下的其它系统也可以打开。