我无法使用ipv4地址访问我的应用程序,它只能从本地主机运行。 我使用vue cli生成模板。继承人代码:
我尝试用Google搜索它,但没有找到真正有用的答案
package.json:
{
"scripts": {
"dev": "webpack-dev-server --inline --progress --config
build/webpack.dev.conf.js --allowed-hosts 192.168.42.126",
"start": "npm run dev",
"lint": "eslint --ext .js,.vue src",
"build": "node build/build.js"
}
}
webpack.dev.conf.js:
devServer: {
clientLogLevel: 'warning',
host: '0.0.0.0',
historyApiFallback: {
rewrites: [{
from: /.*/,
to: path.posix.join(config.dev.assetsPublicPath, 'index.html')
}, ],
},
hot: true,
contentBase: false, // since we use CopyWebpackPlugin.
compress: true,
//host: HOST || config.dev.host,
port: PORT || config.dev.port,
open: config.dev.autoOpenBrowser,
overlay: config.dev.errorOverlay ?
{
warnings: false,
errors: true
} :
false,
publicPath: config.dev.assetsPublicPath,
proxy: config.dev.proxyTable,
quiet: true, // necessary for FriendlyErrorsPlugin
watchOptions: {
poll: config.dev.poll,
}
},