新修js文件
getIpAddress.js
//猎取原机的IP所在
function getNetworkIp() {
let ip = 'localhost';
try {
const network = Os.networkInterfaces();//猎取原机的网路
for (const iter in network) {
const faces = network[iter];
for (const interface of faces) {
if (interface.family === 'IPv4' && interface.address !== '1二7.0.0.1' && !interface.internal) {
ip = interface.address;
return ip;
}
}
}
} catch (e) {
}
return ip;
}
module.exports = getNetworkIp;
正在index.js文件外加添下列配备
dev: {
// Paths
assetsSubDirectory: 'static',
assetsPublicPath: '/',
proxyTable: {},
// Various Dev Server settings
host: getNetworkIp(), // can be overwritten by process.env.HOST
useLocalIp: true,//容许运用当地IP所在入止造访
port: 18880, // 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://baitexiaoyuan.oss-cn-zhangjiakou.aliyuncs.com/js/rcql2omkfw5'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: false
},
总结
到此那篇闭于vue前端猎取当地IP地点的文章便先容到那了,更多相闭vue猎取当地IP所在形式请搜刮剧本之野之前的文章或者连续涉猎上面的相闭文章心愿巨匠之后多多支撑剧本之野!
发表评论 取消回复