ReferenceError: plus is not defined

Developed with uni-app, I want to get the mac address of the machine, but I found a piece of code from the Internet as follows

var net = plus.android.importClass("java.net.NetworkInterface")  
var wl0 = net.getByName('wlan0')  
var macByte = wl0.getHardwareAddress()  
var str = ''  
//下面这段代码来自网络  
for (var i = 0; i < macByte.length; i++) {
    
      
    var tmp = "";  
    var num = macByte[i];  
    if (num < 0) {
    
            
      tmp =(255+num+1).toString(16);  
    } else {
    
      
      tmp = num.toString(16);  
    }  
    if (tmp.length == 1) {
    
      
      tmp = "0" + tmp;  
    }  
    str += tmp;  
}  
console.log('mac', str)

Running it directly gives an error
insert image description here

Says plus is not defined.
This is because it runs directly into an ordinary browser, and ordinary browsers do not have a plus environment.

Connect directly to our mobile phone through USB and run without error!
And also get the correct mac address

Guess you like

Origin blog.csdn.net/changyana/article/details/124152157