1、首先设置localhost和本地ip访问
在config文件下的index.js文件中,修改host为:
host: '0.0.0.0',
port: 8080,
2、设置启动后终端显示localhost和network访问地址
修改build文件下webpack.dev.conf.js文件里compilationSuccessInfo的messages属性值
compilationSuccessInfo: {
// 修改启动后终端显示localhost和network访问地址
messages: [
`App runing at: `,
`Local: http://localhost:${port}`,
`Network: http://${require('ip').address()}:${port}`,
],
}
进行上面的2步的配置后,就可以进行localhost访问和ip地址访问了
转载:https://blog.csdn.net/qq_41497443/article/details/108577543