您的位置:首页 > 产品设计 > UI/UE

【vue-cli】vue-cli+webpack配置下局域网,手机无法访问绑定ip的vue项目

2018-03-08 23:03 1661 查看
http://192.168.0.104:8080/#/    访问我的vue项目,浏览器可以打开,手机无法打开,在同一局域网段下。

1.设置config文件下的index.js文件: dev: {

// Paths
assetsSubDirectory: 'static',
assetsPublicPath: '/',
proxyTable: {},

// Various Dev Server settings
host: '192.168.0.104', // 也可以设置为0.0.0.0
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-
// Use Eslint Loader?
// If true, your code will be linted during bundling and
// linting errors and warnings will be shown in the console.
useEslint: true,
// If true, eslint errors and warnings will also be shown in the error overlay
// in the browser.
showEslintErrorsInOverlay: false,

/**
* Source Maps
*/

// https://webpack.js.org/configuration/devtool/#development devtool: 'cheap-module-eval-source-map',

// If you have problems debugging vue-files in devtools,
// set this to false - it *may* help
// https://vue-loader.vuejs.org/en/options.html#cachebusting cacheBusting: true,
cssSourceMap: true
},如果手机还是无法访问,请:
1.电脑cmd ping手机ip,是否能通。
不能通,好吧,那就
1).把防火墙关闭试试
2).手机和电脑要用同一个wifi,然后打开cmd, ipconfig 看下ip是什么,把这个本机的192.168.0.102换掉,端口号仍然需要的,然后在手机端浏览器中输入新的地址
3).关闭路由器的ap隔离
4).电脑弄代理,在手机的wifi里手动把代理服务器的地址设置好
OK,如果还是不能通,那就vue项目里边的package.json打开: "dev": "webpack-dev-server --inline --progress --config build/webpack.dev.conf.js --port 8080 --host 192.168.0.104",加上粗线的东东,
OK,还不行,翻一翻webpack的配置吧。
附上一个webpack解决此问题的连接:https://github.com/webpack/webpack-dev-server/issues/147
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: