vue把localhost改成ip地址无法访问—解决方法
开发Vue spa 商城进行真机测试的时候,原本在/config下的index.js/host'use strict'// Template version: 1.3.1// see http://vuejs-templates.github.io/webpack for documentation.const path = require('path')module.expor...
·
开发Vue spa 商城进行真机测试的时候,原本在/config下的index.js/host
'use strict'
// Template version: 1.3.1
// see http://vuejs-templates.github.io/webpack for documentation.
const path = require('path')
module.exports = {
dev: {
// Paths
assetsSubDirectory: 'static',
assetsPublicPath: '/',
// Various Dev Server settings
// host: 'localhost'
host: '192.168.xx.xx', // can be overwritten by process.env.HOST
port: 8080, // can be overwritten by process.env.PORT, if port is in use, a free one will be determined
autoOpenBrowser: false,
errorOverlay: true,
notifyOnErrors: true,
poll: false, // https://webpack.js.org/configuration/dev-server/#devserver-watchoptions-
proxyTable: {
'/api': {
target: 'xxxxxxxxxx',
secure: false,
changeOrigin: true,
pathRewrite: {'^/api': ''}
}
},
/**
* Source Maps
*/
devtool: 'cheap-module-eval-source-map',
cacheBusting: true,
cssSourceMap: true
}
}
今天突然不行了,解决办法:
"dev": "webpack-dev-server --inline --progress --config build/webpack.dev.conf.js --host 192.168.x.xxx",
// 修改的是本地的ip
再进行重新运行一下 npm install
npm run dev 运行一下就可以了
//浏览器里面输入
http://192.168.xx.xx:8080/index
自行备注,也希望可以帮到你。
更多推荐
已为社区贡献8条内容
所有评论(0)