vue 本地的项目别人怎么通过你本地 ip地址来访问项目
2020-06-02 本文已影响0人
小呆糊总
解决方法:
1.需要将build文件下的webpack.dev.conf.js里面的const devWebpackConfig上面的
const HOST = process.env.HOST
改为
const HOST = process.env.HOST || '0.0.0.0'
2.然后
const devWebpackConfig = merge(baseWebpackConfig, {
devServer: {host: HOST || config.dev.host }
})
3.另外devWebpackConfig.plugins.push的messages: 由
http://${config.dev.host}:${port}
要改为
http://${devWebpackConfig.devServer.host}:${port}
devWebpackConfig.plugins.push(new FriendlyErrorsPlugin({
compilationSuccessInfo: {
messages: [`Your application is running here: http://${devWebpackConfig.devServer.host}:${port}`],
},
onErrors: config.dev.notifyOnErrors
? utils.createNotifierCallback()
: undefined
}));