//获取ip地址
getIPAdress() { let interfaces = require('os').networkInterfaces(); for (var devName in interfaces) { var iface = interfaces[devName]; for (var i = 0; i < iface.length; i++) { let alias = iface[i]; if (alias.family === 'IPv4' && alias.address !== '127.0.0.1' && !alias.internal) { console.log(alias.address); } } } },
//获取hostName
getHostName() { let os = require('os'); console.log(os.hostname()) },
//获取mac地址,首先要安装getmac依赖----- npm install --save getmac
require('getmac').getMac(function(err,macAddress){ console.log(macAddress) })