mui监听网络变化

document.addEventListener('netchange',onNetChange,false)
        function onNetChange(){
            var nt = plus.networkinfo.getCurrentType();
            switch(nt){
                case plus.networkinfo.CONNECTION_ETHERNET:
            case plus.networkinfo.CONNECTION_WIFI:                      
                 return callback('Wifi')
                     break; 
            case plus.networkinfo.CONNECTION_CELL2G:
            case plus.networkinfo.CONNECTION_CELL3G:
            case plus.networkinfo.CONNECTION_CELL4G:                    
                 return callback('2/3/4G')                       
                 break; 
            default:
                 return callback('no')
                 mui.toast('请检查您的网络设置')
                  break;        
                }
            }

你可能感兴趣的:(mui监听网络变化)