vue webpack模板开启局域网访问

修改config/index.js文件:

1
2
3
4
5
6
7
8
9
const { networkInterfaces } = require('os')
const getIpAddress = () => (networkInterfaces().en0 || networkInterfaces().en4).filter(({ family }) => family === 'IPv4')[0].address

dev: {
...
host: getIpAddress()
...
}