【vue】vue.config.js里面获取本机ip:
•
前端
文章目录
-
-
-
- 一、效果:
- 二、实现:
-
-
一、效果:

二、实现:
const os = require('os');
function getLocalIpAddress() {
const interfaces = os.networkInterfaces();
for (let key in interfaces) {
const iface = interfaces[key];
for (let i = 0; i < iface.length; i++) {
const alias = iface[i];
if (alias.family === 'IPv4' && alias.address !== '127.0.0.1' && !alias.internal) {
return alias.address;
}
}
}
return '0.0.0.0';
}
console.log(getLocalIpAddress())

本文来自网络,不代表协通编程立场,如若转载,请注明出处:https://net2asp.com/82acb246f2.html
